Skip to content

Network Automation

My journey with Network & Cloud Automation

Menu
  • Beginner
  • DevOps-NetDevOps
  • Network Automation
    • Docker
    • Python Libraries
      • NAPALM
      • Netmiko
      • Jinja2
      • Scrapli
      • Yang
  • Cloud Automation
    • Terraform
  • Python 🐍 Tips and Tricks
Menu
docker for network engineers

Docker for Network Engineers Part II – Installation and Basic Usage

Posted on September 10, 2021September 14, 2021 by Gurpreet Kochar

Read Part I here

Docker for Network Engineers Part I – An Introduction
  1. Installing Docker

Download docker from the official website for your platform.

SignUP for Docker Hub. Docker Hub is an online repository of container images made by the official vendors or the community that you can use as a template to build your own application and save them as new containers and share them back with the community.

2. Launch Docker application.

3. Go to Docker Hub and search for Ubuntu

4. Scroll down and look for the tags that you want to pull down from the docker hub to your local machine.

5. Basic Docker CLI

Download the 21.04 version. and the CLI to do so is

docker pull ubuntu:21.04
OR
docker pull ubuntu:hirsute
OR
docker pull ubuntu:rolling

If you look at the bottom, there are 2 ubuntu images with 21.04 and a hirsute tag. They are the same images but since I downloaded them with different tag names, they show up separately. So we will delete one of them.

At this step, we have a ubuntu docker image but not a container. The image needs to be first containerized before you can run it and access it to build your app inside it. To list all containers, we can use “docker ps -a”

There is no ubuntu container at the moment.

Let’s run the image to build a container out of it.

— name flag is used to name your container with a custom name. If you don’t specify a name, docker will automatically generate a name and assign it to your container. There are a ton of other flags that you can use while creating a container that will determine the behavior of that container.

  • -d —- run in detached mode as a background service
  • -p —- forward the ports between container and the host operating system
  • -i —– Keep STDIN open even if not attached.
  • -t —– tty session with the container
  • -V —- mount the local partition with container partition

-it means to keep the session open into the container the moment the container is created.

Execute a command immediately after the container is created. Usually done for some initialization scripts

You can also mount volumes between the host machine and the container.

I am currently inside the docker_demo_1 folder and it’s empty. With the above command using the -v flag. I am trying to mount the current working directory with the/usr/src folder inside the container.

Now you can exchange files to and fro from the container and the host operating system.

In the next part of this series, we will build a python script inside this docker container and build the image from that container to distribute.

Docker for Network Engineers Part III – Creating a custom docker image/container

Know someone who may benefit? Share this:

  • Tweet
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to email a link to a friend (Opens in new window) Email
  • More
  • Click to print (Opens in new window) Print
  • Click to share on Reddit (Opens in new window) Reddit
  • Share on Tumblr
  • Pocket

Like this:

Like Loading...

Related

3 thoughts on “Docker for Network Engineers Part II – Installation and Basic Usage”

  1. Pingback: Docker for Network Engineers Part IV - What is a Dockerfile – Network Automation
  2. Pingback: Docker for Network Engineers Part I - An Introduction – Network Automation
  3. Pingback: Docker for Network Engineers Part III - Creating a custom docker image/container – Network Automation

Leave a ReplyCancel reply

All Blog Posts
My Resume

Upcoming Posts

Sorry - nothing planned yet!

Recent Posts

  • How to backup configuration to TFTP Server using Ansible – Part II
  • How to backup network devices using Ansible – Part I
  • Netmiko SSH Proxy/JumpServer
  • A short note on SASE
  • Understanding Ansible

Recent Comments

  1. Jack on Multithreading with Python for Network Engineers
  2. LifeCanvas on [Theory] Multithreading vs Multiprocessing vs AsyncIO
  3. Jasper Horng on Netmiko SSH Proxy/JumpServer
  4. asdfasdf on Python API Using FASTAPI – UPDATE – PUT – PATCH – Part V
  5. Gurpreet Kochar on Python Scrapli AsyncIO Usage

Archives

  • September 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
Topic Request / Suggestion
Loading
© 2025 Network Automation | Powered by Minimalist Blog WordPress Theme
 

Loading Comments...
 

    %d