Create the volume that Portainer Server will use to store its database:
docker volume create portainer_data

Download and install the Portainer Server container:
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
– Run the container in daemon mode (-d)
– Expose the ports 8000 and 9443 to the public since they are needed to manage the Portainer Server (-p 8000:8000 -p 9443:9443)
– Name the container portainer (--name portainer)
– Set the restart policy to always so the container will start automatically when docker is started (--restart=always)
– Grant the container read-write access to the docker socket (this will enable the container to manage docker containers) (-v /var/run/docker.sock:/var/run/docker.sock)
– Mount the previously created volume portainer_data as /data inside the container (-v portainer_data:/data)
– Use the latest version of the image portainer/portainer-ce (Portainer Community Edition – for Business Edition or Enterprise Edition use portainer/portainer-ee) (portainer/portainer-ce:latest)

Logging in:
– Open this link inside of a modern browser after you have replaced your-fancy-hostname with the hostname or ip address of the host machine.