More samples

Last updated
November 30, 2016

Contributors
Julien Duponchelle
Edit this Article
Last updated
November 30, 2016

Contributors
Julien Duponchelle
Edit this Article

Create a docker container for GNS3

This tutorial is made for user who never used Docker and who want to create a Docker container for GNS3.

First you need to connect to the GNS3 VM and open a shell.

The Docker container are created using a file called Dockerfile.

https://docs.docker.com/engine/reference/builder/

Type:

nano Dockerfile

And put this content inside:

FROM ubuntu:16.04
RUN apt-get update && apt-get install -y nmap

After that run:

docker build -t joe/nmap .

This will build a container named joe/nmap (where joe is your username) based on ubuntu 16.04 and with nmap installed. You can found all the base container here: https://hub.docker.com/r/gns3/

Note: Docker cache each step of the build process.

Now we can use our container in GNS3.

You can replace the shell by a command of your choice using the CMD directive.  Change the Dockerfile to this:

FROM ubuntu:16.04
RUN apt-get update && apt-get install -y nmap
RUN apt-get install -y htop
CMD htop

And rebuild:

docker build -t joe/nmap .

You will need to remove the container from your topology and add it again to see the change:

Now the problem is at each reboot the data changed in your container is lost. If you want to persists stuff you need to use the VOLUME directive:

FROM ubuntu:16.04
RUN mkdir /test
RUN echo "hello" > /test/world
VOLUME /test
WORKDIR /test

After that you can publish your container to the world, anyone will be able to use it by just typing the container name in the docker image field. It’s free. Create an account on

http://hub.docker.com

Run:

docker login
docker push joe/hello

Note: You will need to replace joe by your Docker hub username.

More samples

https://github.com/GNS3/gns3-registry/tree/master/docker