User Tools

Site Tools


docker:containers:run_a_docker_container

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
docker:containers:run_a_docker_container [2020/11/11 12:04] 192.168.1.1docker:containers:run_a_docker_container [2020/11/11 12:12] (current) 192.168.1.1
Line 81: Line 81:
   * **80** is the port of the container where the application is running.   * **80** is the port of the container where the application is running.
  
-<WRAP center round info 60%>+<WRAP info>
 **NOTE:**  You can verify the port 8080 using the URL http://docker-host-ip:8080 in your web browser. **NOTE:**  You can verify the port 8080 using the URL http://docker-host-ip:8080 in your web browser.
  
Line 89: Line 89:
 docker container run -p [host-ip]:[host-port]:[container-port] docker container run -p [host-ip]:[host-port]:[container-port]
 </code> </code>
 +
 +</WRAP>
 +
 +
 +----
 +
 +===== Remove the Container After Exit =====
 +
 +<code bash>
 +docker container run --rm mongo
 +</code>
 +
 +----
 +
 +===== 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 /mnt:/var/www nginx
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  Any data written to **/var/www** within the container is actually accessing **/mnt** on the host.
 +
 +This option is useful for anyone running a database or application that requires persistence within Docker.
  
 </WRAP> </WRAP>
docker/containers/run_a_docker_container.1605096262.txt.gz · Last modified: 2020/11/11 12:04 by 192.168.1.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki