How to install docker on ubuntu server 22.10

Install Docker CE

Here are the steps to install Docker CE (Community Edition) on Ubuntu Server 22.10:

Step 1 : Update the package list:

sudo apt update

Step 2 : Install packages to allow apt to use a repository over HTTPS:

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Step 3 : Add Docker's official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Step 4 : Add the Docker repository:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 5 : Update the package list:

sudo apt update

Step 6 : Install Docker CE:

sudo apt install docker-ce

Step 7 : Verify the installation:

docker --version

Step 8 : Enable the Docker service:

sudo systemctl enable docker

Step 9 : Check the Docker status:

sudo systemctl status docker

Run an Nginx container using the Docker command

Here's how you can run an Nginx container using the Docker command:

Step 10 : Pull the Nginx image from the Docker Hub:

docker pull nginx

Step 11 : Start an Nginx container:

docker run --name mynginx -p 80:80 -d nginx

  • The --name option gives the container a name.
  • The -p option maps the host's port 80 to the container's port 80.
  • The -d option runs the container in the background.

Step 12 : Verify that the container is running:

docker ps

Step 13 : Access the Nginx server:

  • Open your web browser and navigate to http://<host-IP>.
  • Replace <host-IP> with the IP address of the host machine.