docker pull ubuntu

Installing Docker on Ubuntu

To install Docker on Ubuntu, follow these steps:

  1. Remove existing Docker installations: $ sudo apt-get remove docker docker-engine docker.io
  2. Install Docker: $ sudo apt install docker.io
  3. Set up dependencies: $ sudo snap install docker
  4. Test the installation: $ sudo docker run hello-world
  5. View downloaded images: $ sudo docker images
  6. Check running containers: $ sudo docker ps
  7. To use Docker without 'sudo', add user to Docker group: $ sudo usermod -aG docker $USER

Note: Reboot your system to complete the setup.

Pulling an Ubuntu Image

To download an Ubuntu image, you have several options:

  • Latest version: $ docker pull ubuntu
  • Specific version (e.g., 20.04): $ docker pull ubuntu:20.04
  • Pull by digest for unchanging image: $ docker pull ubuntu@sha256:<digest>
  • Pull from different registries: $ docker pull myregistry.local:5000/ubuntu

After pulling, view downloaded images with: $ docker images

Running and Interacting with Containers

To run and interact with an Ubuntu container:

  1. Launch interactive terminal session: $ docker run -ti --rm ubuntu /bin/bash
  2. Inside the container, check OS information: root@container_id:/# cat /etc/os-release
  3. Create persistent storage link: $ docker run -ti --rm -v ~/Docker_Share:/data ubuntu /bin/bash

This mounts a local directory (~/Docker_Share) to /data in the container.

Managing Docker Images and Containers

Efficient management of Docker images and containers involves several key commands:

ActionCommand
List images$ docker images
View all containers$ docker ps -a
Label images$ docker tag original-image-name:tag new-image-name:new-tag
Create new image from running container$ docker commit container_id new-image-name
Remove unused images$ docker rmi image_id
Delete unnecessary containers$ docker rm container_id

For bulk removal, use these commands:

  • $ docker system prune
  • $ docker image prune
  • $ docker volume prune
A visual representation of Docker image and container management, showing images being transformed into running containers

By following these steps, you can effectively use Docker's capabilities to enhance your development environment. Remember that Docker's flexibility allows for efficient management of both images and containers, enabling a streamlined workflow for developers and system administrators alike.

  1. Docker Documentation. Docker Engine installation overview. Docker Inc.
  2. Ubuntu Documentation. Docker. Canonical Ltd.
  3. Mouat N. Using Docker: Developing and Deploying Software with Containers. O'Reilly Media; 2015.

Leave a Reply