In this article, sharing about how to install the docker with docker compose on Ubuntu, and all basic operations.

Installations

  1. Update the package list: Run the following command in the terminal
1
sudo apt update
  1. Install necessary packages to allow apt to use a repository over HTTPS
1
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
  1. Add Docker’s official GPG key
1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  1. Set up the stable repository
1
2
3
echo \
"deb [arch=amd64 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
  1. Update the package list again to include the Docker repository
1
sudo apt update
  1. Install docker
1
sudo apt install -y docker-ce docker-ce-cli containerd.io
  1. Verify that Docker is installed correctly by running the following command
1
sudo docker --version
  1. Start and enable the Docker service
1
2
sudo systemctl start docker
sudo systemctl enable docker

Basic Commands

  1. Check current running containers
1
sudo docker ps
  1. Check all containers
1
2
h
sudo docker ps -a
  1. Stop a container
1
sudo docker stop {Container_ID}
  1. Get into container
1
sudo docker run -it {Container_ID} /bin/sh
  1. Copy a file from container to local
1
sudo docker cp /path/on/container /path/on/local/machine