Run container in Docker host
# pull image (download image to local)
docker pull httpd:latest
To run a container we need a port
Types of ports in docker:
- Static port -p <port to access>:<application port>
Ex: apache application port 80
-p 8080:80
docker images
i Info → U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
demo-ubuntu:1.0 2b4a4d589d5e 157MB 41.6MB
httpd:2.4.68 979c38c2228d 177MB 47.6MB
httpd:latest 979c38c2228d 177MB 47.6MB
docker run -dit –name apache2 -p 8080:80 httpd:latest
Dynamic port
docker run -dit –name tomcat -P tomcat:9.0
Stop and clean containers and images
- Container commands
docker stop <container id>
docker rm <container id>
docker rm -f <container id>
docker rm -f $(docker ps -a -q)


## Create container
docker create --name tomcat2 -p 8081:8080 tomcat:9.0
## Start container
docker start <container id>
## docker run
docker create + docker start
