Hier sind ein paar nützliche Tipps und Notizen für Docker zusammen gefasst.
Hier ein paar nützliche Befehle. $container, $image und $tag stehen für einen Beispiel Container-Namen, Image und Tag.
docker exec -it $container bash
docker logs $container
docker run -it --rm $image:$tag
Create a Dockerfile
with these contents:
FROM mysql:5 ADD db.sql /docker-entrypoint-initdb.d/db.sql
Add a db.sql
file into the same directory as the Dockerfile
with your sql scheme:
CREATE TABLE IF NOT EXISTS `uni`.`grades` ( `id` INT PRIMARY KEY AUTO_INCREMENT NOT NULL, `semester` VARCHAR(255), `datum` VARCHAR(255), `note` VARCHAR(255), `id_student` INT );
Build and run your container:
docker build -t your_db:latest . docker run --name your_db -e MYSQL_ROOT_PASSWORD="$somerandompass" -e MYSQL_DATABASE="$databasename" -d your_db:latest
More about building your own images see: dockerfile