-
Notifications
You must be signed in to change notification settings - Fork 44
NOTE20210721
Somkiat Puisungnoen edited this page Jul 21, 2021
·
7 revisions
docker container run hello-world
docker container run hello-world:latest
docker image ls
docker container ps
docker container ps -a
docker container prune
- Docker Image
- hello-world:latest
- name:tag
- Docker Registry
- Dockerfile
- Docker Container
$docker container run -d --name db \
-e MYSQL_RANDOM_ROOT_PASSWORD=yes \
-e MYSQL_DATABASE=demo \
-e MYSQL_USER=somkiat \
-e MYSQL_PASSWORD=pass \
mysql:8.0.26
$docker container ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1b95c3d76c1b mysql:8.0.26 "docker-entrypoint.s…" 49 seconds ago Up 48 seconds 3306/tcp, 33060/tcp db
$docker container logs db --follow
Initial data of container
file data.sql
use demo;
CREATE TABLE user (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(30) NOT NULL
);
INSERT INTO user(name) VALUES ("A");
INSERT INTO user(name) VALUES ("B");
INSERT INTO user(name) VALUES ("C");
$docker container run -d --name db \
-e MYSQL_RANDOM_ROOT_PASSWORD=yes \
-e MYSQL_DATABASE=demo \
-e MYSQL_USER=somkiat \
-e MYSQL_PASSWORD=pass \
-v $(pwd)/data.sql:/docker-entrypoint-initdb.d/1.sql \
mysql:8.0.26
$docker container logs db --follow
$docker container exec -it db bash
#mysql -usomkiat -ppass
#use demo
#show tables;
#select * from user;