Getting Portainer up and running

We are first going be looking at using Portainer to manage a single Docker instance running locally. I am running Docker for Mac so I will be using that, but these instructions should also work with other Docker installations.

First of all, let's grab the container image from the Docker Hub by running the following commands:

$ docker image pull portainer/portainer
$ docker image ls

As you can see when we ran the docker image ls command, the Portainer image is only 9.96 MB. To launch Portainer, we simply have to run the following command:

$ docker container run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer
As you can see from the command we have just run, we are mounting the socket file for the Docker Engine on our Docker Host machine. Doing this will allow Portainer full unrestricted access to the Docker Engine on our host machine. It needs this so it can manage Docker on the host; however, it does mean that your Portainer container has full access to your host machine, so be careful in how you give access to it and also when publicly exposing Portainer on remote hosts.

For the most basic type of installation, that is all we need to run. There are a few more steps to complete the installation; they are all performed in the browser. To complete them, go to http://localhost:9000/.

The first screen you will be greeted by asks you to set a password for the admin user:

Once you have set the password, you will be taken to a login page: enter the username admin and the password you just configured. Once logged in, you will be asked about the Docker instance you wish to manage. There are two options:

  • Manage the Docker instance where Portainer is running
  • Manage a remote Docker instance

For the moment, we want to manage the instance where Portainer is running:

As you can see, there is a message that says the following:

This feature is not yet available for native Docker Windows containers. On Linux and when using Docker for Mac or Docker for Windows or Docker Toolbox, ensure that you have started Portainer container with the following Docker flag -v "/var/run/docker.sock:/var/run/docker.sock"

As we have already taken mounting the Docker socket file into account when launching our Portainer container, we can click on Connect to complete our installation. This will take us straight into Portainer itself, showing us the dashboard.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset