# Update existing packages list
$ sudo apt update
# Install packages required for HTTPS apt packages
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common
# Add the GPG key for the official Docker repository and docker repository
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
$ apt-cache policy docker-ce
# Install docker
$ sudo apt install docker-ce
$ sudo systemctl status docker
Executing the Docker Command Without Sudo
# add a user ($USER) to the docker group
$ sudo usermod -aG docker ${USER}
$ su - ${USER}
$ groups
# Using the Docker Command
$ docker [option] [command] [arguments]
$ docker
Working with Docker images
# Verify if you can access Docker Hub
$ docker run hello-world
# Sample output
Output
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
# Search images availble in the Docker Hub
$ docker search ubuntu
# Downloading an images
$ docker pull ubuntu
# See available images
$ docker images
Running a Docker image
# The combination of the -i and -t switches gives you interactive shell access into the container:
$ docker run -it ubuntu
# Command prompt that indicate you are inside the container
# Output
root@d8b600b2f738:/#
Managing Docker Container
# View Active Containers
$ docker ps
# View active and inactive Containers
$ docker ps -a
# View latest Container created
$ docker ps -l
# Start a Container
$ docker start <image id>
# Remove container using name
docker rm <container name>
# Committing changes
docker commit -m "commit message or description" -a "Author Name" container_id repository/new_image_name
# Nginx packages
sudo apt update
sudo apt install nginx
#verify nginx serivce
systemctl status nginx
# test web service, replace the "your_server_ip with the address of your nginx server"
http://your_server_ip
* You should receive the default Nginx landing page
Installing and configuring Docker Registry using Docker Compose