Docker On Ubuntu - jhu-information-security-institute/infrastructure GitHub Wiki

Install Docker on Ubuntu server x86-64

  • See here for more information
  • Create virtual disk for Docker as outlined here
  • Install dependencies using $ sudo apt-get install ca-certificates curl
  • Add Docker’s official GPG key:
    $ sudo install -m 0755 -d /etc/apt/keyrings
    $ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
    $ sudo chmod a+r /etc/apt/keyrings/docker.asc
    
  • Setup the repository using:
    $ echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
      $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
      sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    
  • Update APT using $ sudo apt-get update
  • Install Docker packages using $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  • Enable permissions for your user (requires logout or reboot): # usermod -aG docker <USERNAME>
  • Customize storage management for Docker as outlined here
  • Enable the Docker daemon using $ sudo systemctl enable docker
  • Test Docker was installed correctly: $ docker run hello-world
  • Shut the VM down, snapshot your VM, and name it "Docker install"

Docker usage specifics for Ubuntu

  • Create a default Ubuntu container
    • Pull a default docker container for Ubuntu using $ docker pull ubuntu:22.04
  • Run it using $ docker run -it ubuntu:22.04 bash
⚠️ **GitHub.com Fallback** ⚠️