Docker Volumn

04/01/2022   Docker

Docker Volumn

docker volume --help

- docker volume create demo-vol
=> create volume demo-vol

- docker run -it \
-p 9000:80 \
-v demo-vol:/var \
ubuntu bash
=> using demo-vol for container, data in volume is persit

- docker run -dp 3000:3000 -v demo-vol:/etc/todos getting-started
=> create container with volumn demo-vol connect with /ect/todos directory in container

- docker run -it --platform "linux/amd64" -e MYSQL_ROOT_PASSWORD=secret mysql:5.7
=> run container with image mysql

- docker exec -it containerId mysql -u root -p 
=> mysql -u root -p  (is command)

- docker run -it --platform "linux/amd64" -e MYSQL_ROOT_PASSWORD=secret -e MYSQL_DATABASE=todos mysql:5.7
=> run container with image mysql

- docker run -it -d -p 9000:80 -v ~/path-host-directory:/path-container-directory ubuntu  
=> docker run -it -d -p 9000:80 -v ~/path-host-directory:/var/www/html ubuntu   
=> connect host directory with container directory


Bài viết cùng chủ đề