Image for post
Image for post

Installing docker in ubuntu and running some commands to deploy your first docker container!!

Sumyak Jain
Nov 20 · 5 min read

What is Docker?

Containerization is increasingly popular because containers are:

  • Flexible: Even the most complex applications can be containerized.
  • Lightweight: Containers leverage and share the host kernel, making them much more efficient in terms of system resources than virtual machines.
  • Portable: You can build locally, deploy to the cloud, and run anywhere.
  • Loosely coupled: Containers are highly self-sufficient and encapsulated, allowing you to replace or upgrade one without disrupting others.
  • Scalable: You can increase and automatically distribute container replicas across a datacenter.
  • Secure: Containers apply aggressive constraints and isolations to processes without any configuration required on the part of the user.

What is a Container?

Installing docker in Ubuntu:

1) First, in order to ensure the downloads are valid, add the GPG key for the official Docker repository to your system

using the command below:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Image for post
Image for post

2) Add the Docker repository to APT sources

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Image for post
Image for post

3) Next, update the package database with the Docker packages from the newly added repo

$ sudo apt-get update
Image for post
Image for post

4) Make sure you are about to install from the Docker repo instead of the default Ubuntu 16.04 repo

$ apt-cache policy docker-ce
Image for post
Image for post

5) Finally, install your Docker

$ sudo apt-get install -y docker-ce
Image for post
Image for post

6) To Check whether it’s in running condition or not

$ sudo systemctl status docker
Image for post
Image for post

7) Check yourdocker version after installation

$ docker --version
Image for post
Image for post

CONGRATULATIONs YOU HAVE SUCCESSFULLY INSTALLED DOCKER IN YOUR SYSTEM !!!

Now its time to know how to deploy your first docker container?

Deploy your first docker container?

STEP 1) For example purpose we will be deploying container of “redis” docker image:

search for the docker image “redis”

docker search redis

This command will Search the Docker Hub for images

Image for post
Image for post

You can also cross check it by searching it on dockerhub

Image for post
Image for post

STEP 2) Pull docker image

docker pull redis

This command will Pull an image or a repository from a registry

Image for post
Image for post

STEP 3) Start the container using

this command automatically pull the image and start the container

docker run -d redis

The docker run command must specify an IMAGE to derive the container from. An image developer can define image defaults related to:

  • detached or foreground running
  • container identification
  • network settings
  • runtime constraints on CPU and memory

With the docker run [OPTIONS] an operator can add to or override the image defaults set by a developer. And, additionally, operators can override nearly all the defaults set by the Docker runtime itself. The operator’s ability to override image and Docker runtime defaults is why run has more options than any other docker command.

Detached (-d): To start a container in detached mode, you use -d=true or just -d option. By design, containers started in detached mode exit when the root process used to run the container exits, unless you also specify the --rm option. If you use -d with --rm, the container is removed when it exits or when the daemon exits, whichever happens first.

Image for post
Image for post

You can check for list of containers and there status using but this will just give you 2 linked containers

docker ps
Image for post
Image for post

to see all the containers you can use

docker ps -a
Image for post
Image for post

You can also inspect the container using the command this will Return low-level information on Docker objects

docker inspect <container id | friendly name>

output using container id

Image for post
Image for post

output using container name

Image for post
Image for post

You can also see container log using

docker logs <container id | friendly name>
Image for post
Image for post

Congratulations!! you have successfully learned how to install Docker in Ubuntu and deploy your first Docker Container.

Image for post
Image for post

👋 Join FAUN today and receive similar stories each week in your inbox! Get your weekly dose of the must-read tech stories, news, and tutorials.

Follow us on Twitter 🐦 and Facebook 👥 and Instagram 📷 and join our Facebook and Linkedin Groups 💬

Image for post
Image for post

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author! ⬇

FAUN

The Must-Read Publication for Creative Developers & DevOps Enthusiasts

Sign up for FAUN

By FAUN

Medium’s largest and most followed independent DevOps publication. Join thousands of aspiring developers and DevOps enthusiasts Take a look

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Sumyak Jain

Written by

I am Sumyak Jain Pursuing B.tech in Computer Science Engineering with specialization in DevOps at UPES, Dehradun

FAUN

FAUN

The Must-Read Publication for Creative Developers & DevOps Enthusiasts. Medium’s largest DevOps publication.

Sumyak Jain

Written by

I am Sumyak Jain Pursuing B.tech in Computer Science Engineering with specialization in DevOps at UPES, Dehradun

FAUN

FAUN

The Must-Read Publication for Creative Developers & DevOps Enthusiasts. Medium’s largest DevOps publication.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store