Docker Basic

Install Docker (Ubuntu)

Uninstall Old Versions

sudo apt-get remove docker docker-engine docker.io containerd runc

Set up the Repository

sudo apt-get update

sudo apt-get install ca-certificates curl gnupg lsb-release

sudo mkdir -p /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

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

Install Docker Engine

Verify that Docker Engine is installed correctly by running the hello-world image.

Docker Images

Ref: https://docs.docker.com/engine/reference/commandline/image/

Build an image from a Dockerfile

Docker Containers

Ref: https://docs.docker.com/engine/reference/commandline/container/

Run Container in Attach mode

Run Container in Detach mode

Run a command in a running container

  • --interactive or -i: Keep STDIN open even if not attached

  • --tty or -t: Allocate a pseudo-TTY

Display detailed information on one or more containers

List port mappings or a specific mapping for the container

Remove one or more containers

Remove all stopped containers

Docker Networking

Last updated

Was this helpful?