In this article, sharing about how to install the docker with docker compose on Ubuntu, and all basic operations.
Installations
- Update the package list: Run the following command in the terminal
1 | sudo apt update |
- 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 |
- 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 |
- Set up the stable repository
1 | echo \ |
- Update the package list again to include the Docker repository
1 | sudo apt update |
- Install docker
1 | sudo apt install -y docker-ce docker-ce-cli containerd.io |
- Verify that Docker is installed correctly by running the following command
1 | sudo docker --version |
- Start and enable the Docker service
1 | sudo systemctl start docker |
Basic Commands
- Check current running containers
1 | sudo docker ps |
- Check all containers
1 | h |
- Stop a container
1 | sudo docker stop {Container_ID} |
- Get into container
1 | sudo docker run -it {Container_ID} /bin/sh |
- Copy a file from container to local
1 | sudo docker cp /path/on/container /path/on/local/machine |