Docker Notes - 2023
Docker Notes - 2023
==============
sudo apt update -y (This command will update the package index cache in the server)
sudo apt install docker.io -y (docker.io)
sudo systemctl start docker (docker service will be started in runtime)
sudo systemctl enable docker (this will start the service at the boot time)
sudo docker info
docker image ls
To deploy container with container image in interactive mode
docker ps
docker ps -a
docker ps -s
To stop a running container
docker stats
docker rm -f container_name
To forcefully remove a image which is in use by a running container (Note: This will not
impact the running container)
To rename a container
To map container port with host port to expose application over host network
apt update -y
apt install apache2 git -y
cd /var/www/html
git clone https://github.com/devopstraining99/demo-app
cd /etc/init.d/
./apache2 start
touch Dockerfile
nano Dockerfile
FROM ubuntu
RUN apt update -y && apt install apache2 git -y
RUN cd /var/www/html && git clone https://github.com/devopstraining99/demo-app
ENTRYPOINT apache2ctl -DFOREGROUND
EXPOSE 80
# Docker file
FROM ubuntu
RUN apt update -y && apt install apache2 -y
WORKDIR /var/www/html (1) The path which will be used during docker build
2) the path in which the user will be logged-in when the container is deployed