Install Docker Engine on Debian
https://docs.docker.com/engine/install/debian/
Install Docker Compose
https://docs.docker.com/compose/install/
Create the docker group.
sudo groupadd docker
Add your user to the docker group.
sudo usermod -aG docker $USER
activate the changes to groups:
newgrp docker
Verify that you can run docker commands without sudo.
docker run hello-world
docker images - Will show all top level images, their repository and tags, and their size.
docker search key_word - Search the Docker Hub for images
docker pull image_name - Pull an image from Docker Hub
docker ps - List just running containers
docker ps -a - Show all containers
docker run image_name - Run a command in a new container
docker stop id_container - Stop one or more running containers
docker rmi image_name - Remove one or more images
docker rm container_name - Remove one or more containers
Run tomcat image interactively (-it Run a container interactively, -p 8000:8080 This binds port 8080 of the container to port 8000 of the host machine.)
docker run -it -p 8000:8080 tomcat
Checking:
curl -I 127.0.0.1:8080
or http://localhost:8080
Run tomcat image like daemon (- d Run container in background and print container ID)
docker run -d -p 8000:8080 tomcat
If you have HTTP Status 404 – Not Found Docker Tomcat Image
https://www.topzenith.com/2020/07/http-status-404-not-found-docker-tomcat-image.html
mkdir project0
cd project0
nano Dockerfile
# FROM instruction initializes a new build stage and sets the Base Image for subsequent instructions.
FROM ubuntu:16.04
# Author info
MAINTAINER Vasia email@gmail.com
# The RUN instruction will execute any commands in a new layer on top of the current image and commit the results. The resulting committed image will be used for the next step in the Dockerfile.
RUN apt-get -y update
RUN apt-get -y install apache2
RUN echo 'Hello World' > /var/www/html/index.html
# CMD is to provide defaults for an executing container.
CMD ["/usr/sbin/apache2ctl", "-D","FOREGROUND"]
# EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime.
EXPOSE 80
Build an image from a Dockerfile, -t Name and optionally a tag in the 'name:tag' format.
docker build -t name:tag .
Run a new container
docker run -d -p 8080:80 name:tag
docker exec command runs a new command in a running container.
docker exec -it container_id /bin/bash
Create a new image from a container’s changes
docker commit container_id image_name:tag