How to create a web container with docker.

This tutorial shows how to connect to a docker container without stoping it when exiting.

Run the following command:


root@ubuntu:~# docker exec -it containername bash
[root@574a0820f181 /]# 

Here an example showing a container named apache running in docker.
We connect to it, exit the container, then we check that the container is still running in docker.

The output will be:

root@ubuntu:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                NAMES
574a0820f181        om:apache           "/bin/bash"         3 days ago          Up 2 days           0.0.0.0:80->80/tcp   apache
root@ubuntu:~# docker exec -it apache bash
[root@574a0820f181 /]# exit
exit
root@ubuntu:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                NAMES
574a0820f181        om:apache           "/bin/bash"         3 days ago          Up 2 days           0.0.0.0:80->80/tcp   apache
root@ubuntu:~#

References:

Docker

Recent Comments