docker:containers:run_a_docker_container
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
docker:containers:run_a_docker_container [2020/11/11 12:04] – 192.168.1.1 | docker:containers:run_a_docker_container [2020/11/11 12:12] (current) – 192.168.1.1 | ||
---|---|---|---|
Line 89: | Line 89: | ||
docker container run -p [host-ip]: | docker container run -p [host-ip]: | ||
</ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Remove the Container After Exit ===== | ||
+ | |||
+ | <code bash> | ||
+ | docker container run --rm mongo | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Run a Container and Mount Host Volumes ===== | ||
+ | |||
+ | By default, Docker containers do not save the data. When a container is stopped and the process is completed, all data generated by the container is removed. | ||
+ | |||
+ | Sometimes you may need to run a container that requires persistent storage. In that case, you can use Docker volume to make the data persist and also share it across the multiple containers. | ||
+ | |||
+ | <code bash> | ||
+ | docker container run --name docker-nginx -d -p 8080:80 -v / | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | This option is useful for anyone running a database or application that requires persistence within Docker. | ||
</ | </ |
docker/containers/run_a_docker_container.1605096289.txt.gz · Last modified: 2020/11/11 12:04 by 192.168.1.1