Skip to content

Latest commit

 

History

History
56 lines (44 loc) · 2.24 KB

DockerCommands.md

File metadata and controls

56 lines (44 loc) · 2.24 KB

Prerequisites

  • An Ubuntu Linux box
  • The sonic docker image in your home directory.
    • Pre-built sonic-mgmt can also be downloaded from here
  • Basic knowledge of docker commands.
  • Docker-tools should be there installed in your system.

sonic-mgmt docker environment preparation: useful commands (for Ubuntu system)

Installing docker
sudo apt-get update
sudo apt-get remove docker docker-engine docker.io
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker

Unzip sonic Image
gzip -d docker-sonic-mgmt.gz

Load the docker Image
sudo docker images
sudo docker load -i docker-sonic-mgmt
sudo docker run -it --name sonic docker-sonic-mgmt

Stopping a docer session
sudo docker stop sonic

Reconnect to a stopped docer session
sudo docker start -i sonic

When you are done you may remove the image sonic
sudo docker rm sonic

Remove docker by image Id
sudo docker rmi -f <image-id>

Running a sonic docker with local directoy mounted in it.
sudo docker run -it --name sonic --privileged -v /home/ubuntu/adhar/:/var/johnar/adhar --workdir /var/johnar/adhar --user johnar:gjohnar docker-sonic-mgmt

How to run a docker with a port number

Run a docker container with port number -p

  • -itd will run docker in a detached state, I'm using port 2222 you can use any port
    sudo docker run -itd --name sonic -p 2222:22 docker-sonic-mgmt

Enter the docker container using exec
sudo docker exec -it sonic bash

Check ssh service is running inside the docker
johnar@1ed3a9afe70f:~$ service --status-all

If ssh service is not running start ssh
johnar@1ed3a9afe70f:~$ sudo service ssh start

update johnar user passwd

  • update passwd of your choice johnar@1ed3a9afe70f:~$ sudo passwd johnar

use ssh from any machine in the network to login to docker directly
ssh [email protected] -p 2222