Activities
- Create a linux vm and install docker in it
- Create a container with name myhttpd1 and image httpd
- Create a container with name myhttpd2 and image httpd and forwarding 80 port of the container to 32000 port of the linux vm
- Create a container with name interactive and image alpine.
- Verify the containers which are running
- myhttpd1 and myhttpd2 will be in running state and interactive will be in exited state
- Lets remove all the containers
docker container rm -f $(docker container ls -a -q)
- Lets remove all the images
docker image rm -f $(docker image ls -q)
- Lets create a container and login into that during running the container. Lets use alpine and ubuntu docker images
- Lets create the nginx container in detached mode
-d
- Lets create the nginx container in attached mode
- IN detached mode the container will be started in the background whereas in attached mode the container will be started in foreground and STDIN, STDOUT, STDERR of the container will be attached to your terminal. Your terminal becomes unusable.
- To come out of this execute
Ctrl+C
and this will stop container execution
Observations
- Not all the containers when executed will be in running state. the alpine container with the name interactive went into exited state
- Docker container can be executed in 3 ways
- detached
- attached
- interactive