# Instalação e Configuração Portainer

# Install Portainer CE with Docker on Linux

##### Link: [https://docs.portainer.io/start/install-ce/server/docker/linux](https://docs.portainer.io/start/install-ce/server/docker/linux) 

##### **Introduction**

#####   
Portainer consists of two elements, the Portainer Server, and the Portainer Agent. Both elements run as lightweight Docker containers on a Docker engine. This document will help you install the Portainer Server container on your Linux environment. To add a new Linux environment to an existing Portainer Server installation, please refer to the Portainer Agent installation instructions.

##### To get started, you will need:

- ##### The latest version of Docker installed and working. We recommend following the official installation instructions for Docker - in particular, we advise against installing Docker via snap on Ubuntu distributions as you may run into compatibility issues.
- <span style="color: rgb(34, 34, 34); font-family: var(--font-heading, var(--font-body)); font-size: 1.4em; font-weight: 400;">sudo access on the machine that will host your Portainer Server instance;</span>
- <span style="color: rgb(34, 34, 34); font-family: var(--font-heading, var(--font-body)); font-size: 1.4em; font-weight: 400;">By default, Portainer Server will expose the UI over port 9443 and expose a TCP tunnel server over port 8000. The latter is optional and is only required if you plan to use the Edge compute features with Edge agents.</span>

##### The installation instructions also make the following assumptions about your environment:

- ##### Your environment meets our requirements. While Portainer may work with other configurations, it may require configuration changes or have limited functionality.
- <span style="color: rgb(34, 34, 34); font-family: var(--font-heading, var(--font-body)); font-size: 1.4em; font-weight: 400;">You are accessing Docker via Unix sockets. Alternatively, you can also connect via TCP.</span>
- <span style="color: rgb(34, 34, 34); font-family: var(--font-heading, var(--font-body)); font-size: 1.4em; font-weight: 400;">SELinux is disabled on the machine running Docker. If you require SELinux, you will need to pass the --privileged flag to Docker when deploying Portainer.</span>
- <span style="color: rgb(34, 34, 34); font-family: var(--font-heading, var(--font-body)); font-size: 1.4em; font-weight: 400;">Docker is running as root. Portainer with rootless Docker has some limitations, and requires additional configuration.</span>

##### **Deployment**

##### First, create the volume that Portainer Server will use to store its database:

##### *docker volume create portainer\_data*

##### Then, 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:2.21.0*

#####   
By default, Portainer generates and uses a self-signed SSL certificate to secure port 9443. Alternatively you can provide your own SSL certificate during installation or via the Portainer UI after installation is complete.

##### If you require HTTP port 9000 open for legacy reasons, add the following to your docker run command:

##### -p 9000:9000

##### Portainer Server has now been installed. You can check to see whether the Portainer Server container has started by running docker ps:

##### root@server:~# docker ps  
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES   
de5b28eb2fa9 portainer/portainer-ce:2.21.0 "/portainer" 2 weeks ago Up 9 days 0.0.0.0:8000-&gt;8000/tcp, :::8000-&gt;8000/tcp, 0.0.0.0:9443-&gt;9443/tcp, :::9443-&gt;9443/tcp portainer

#####   
**Logging In**

##### Now that the installation is complete, you can log into your Portainer Server instance by opening a web browser and going to:

##### *[https://localhost:9443](https://localhost:9443)*

##### Replace localhost with the relevant IP address or FQDN if needed, and adjust the port if you changed it earlier.

##### You will be presented with the initial setup page for Portainer Server.

# Updating on Docker Standalone

Link: [https://docs.portainer.io/start/upgrade/docker](https://docs.portainer.io/start/upgrade/docker)

<header class="max-w-3xl mx-auto mb-6 space-y-3 page-api-block:ml-0" id="bkmrk-updating-on-docker-s"></header>  
Always match the agent version to the Portainer Server version. In other words, when you're installing or updating to Portainer 2.21.0 make sure all of the agents are also on version 2.21.0.

Before beginning any update, we highly recommend [taking a backup](https://github.com/portainer/portainer-docs/blob/2.21/admin/settings/general/README.md#back-up-portainer) of your current Portainer configuration.

**Updating your Portainer Server**

Starting from Portainer CE 2.9 and BE 2.10, HTTPS is enabled by default on port `9443.` These instructions will configure Portainer to use 9443 for HTTPS and do not expose 9000 for HTTP. If you need to retain HTTP access, you can add: `-p 9000:9000`to your command.  
  
You can also choose to [completely disable HTTP](https://github.com/portainer/portainer-docs/blob/2.21/admin/settings/general/README.md#force-https-only) after the update. Before you make Portainer HTTPS only, make sure you have all your Agents and Edge Agents already communicating with Portainer using HTTPS.

This article assumes that you used our recommended deployment scripts.

  
To update to the latest version of Portainer Server, use the following commands to stop then remove the old version. Your other applications/containers will not be removed.

**docker rm portainer**

  
Now that you have stopped and removed the old version of Portainer, you must ensure that you have the most up to date version of the image locally. You can do this with a `docker pull` command:

<button aria-controls="tabpanel-f80c4f7c1bb340be8582113c169dea2a" aria-selected="true" class="[&:has(+_.active-tab)]:rounded-br-md [.active-tab_+_&]:rounded-bl-md [.active-tab_+_:after]:rounded-br-md inline-block text-sm px-3.5 py-2 transition-[color] font-[500] relative after:transition-colors after:group-hover/tabs:border-transparent after:border-r after:absolute after:left-[unset] after:right-0 after:border-dark/4 after:top-[15%] after:h-[70%] after:w-[1px] last:after:border-transparent hover:text-dark-2 dark:after:border-light/2 dark:hover:text-light-3 truncate max-w-full shrink-0 active-tab text-dark-2 bg-transparent dark:text-light dark:bg-transparent after:[&.active-tab]:border-transparent after:[:has(+_&.active-tab)]:border-transparent after:[:has(&_+)]:border-transparent" id="bkmrk-community-edition" role="tab">  
Community Edition: </button>**docker pull portainer/portainer-ce:2.21.0**

Finally, deploy the updated version of Portainer:

**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:2.21.0**

These `docker run` commands include opening port `8000` which is used for Edge Agent communication as included in our [installation instructions](https://docs.portainer.io/start/install/server/docker/linux). If you do not need this port open, you can remove it from the command.

To provide your own SSL certs you may use `--sslcert` and `--sslkey` flags as below to provide the certificate and key files. The certificate file needs to be the full chain and in PEM format. For example, for Business Edition:

**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-ee:2.21.0 --sslcert /path/to/cert/portainer.crt --sslkey /path/to/cert/portainer.key**

The newest version of Portainer will now be deployed on your system, using the persistent data from the previous version, and will also upgrade the Portainer database to the new version.

When the deployment is finished, go to `https://your-server-address:9443` or `http://your-server-address:9000` and log in. You should notice that the update notification has disappeared and the version number has been updated.

**Agent-only upgrade**

To update to the latest version of Portainer Agent, use the following commands to stop then remove the old version. Your other applications/containers will not be removed.

docker stop portainer\_agent

<div class="grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] [margin-top:_1em]" id="bkmrk--2" style="text-align: justify;">[<svg class="gb-icon w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4"></svg>](https://docs.portainer.io/start/upgrade/docker#updating-your-portainer-server)</div>
<div class="[&>*+*]:mt-5 grid whitespace-pre-wrap" id="bkmrk-copy-2" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; box-sizing: border-box; border: 0px solid rgb(229, 231, 235); display: grid; white-space: pre-wrap; color: color(srgb 0.120353 0.120353 0.120353); font-family: __Inter_207ec3, __Inter_Fallback_207ec3, system-ui, arial; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: color(srgb 1 1 1); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="px-4 py-4 transition-colors rounded-md straight-corners:rounded-none bg-gradient-to-b from-periwinkle/6 to-periwinkle/5 ring-1 ring-inset ring-dark/1 dark:ring-periwinkle/1 dark:from-periwinkle/2 dark:to-periwinkle/[0.1] max-w-3xl w-full mx-auto decoration-primary/6 page-api-block:ml-0"></div></div><div class="grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] [margin-top:_1em]" id="bkmrk--9" style="text-align: justify;">[<svg class="gb-icon w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4"></svg>](https://docs.portainer.io/start/upgrade/docker#agent-only-upgrade)</div>
```
docker stop portainer_agent
```

<div class="[&>*+*]:mt-5 grid whitespace-pre-wrap" id="bkmrk-copy-4" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; box-sizing: border-box; border: 0px solid rgb(229, 231, 235); display: grid; white-space: pre-wrap; color: color(srgb 0.120353 0.120353 0.120353); font-family: __Inter_207ec3, __Inter_Fallback_207ec3, system-ui, arial; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: color(srgb 1 1 1); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="group/codeblock grid grid-flow-col max-w-3xl w-full mx-auto decoration-primary/6 page-api-block:ml-0">  
</div><div class="group/codeblock grid grid-flow-col max-w-3xl w-full mx-auto decoration-primary/6 page-api-block:ml-0"><div class="flex items-center justify-start [grid-area:1/1] text-sm gap-2">  
</div><button class="group-hover/codeblock:opacity-[1] transition-opacity duration-75 opacity-0 text-xs [grid-area:2/1] z-[2] justify-self-end backdrop-blur-md leading-none self-start ring-1 ring-dark/2 text-dark/7 bg-transparent rounded-md mr-2 mt-2 p-1 hover:ring-dark/3 dark:ring-light/2 dark:text-light/7 dark:hover:ring-light/3 print:hidden">Copy</button></div></div>```
docker rm portainer_agent
```

Next, pull the updated version of the image:

<div class="[&>*+*]:mt-5 grid whitespace-pre-wrap" id="bkmrk-copy-5" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; box-sizing: border-box; border: 0px solid rgb(229, 231, 235); display: grid; white-space: pre-wrap; color: color(srgb 0.120353 0.120353 0.120353); font-family: __Inter_207ec3, __Inter_Fallback_207ec3, system-ui, arial; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: color(srgb 1 1 1); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="group/codeblock grid grid-flow-col max-w-3xl w-full mx-auto decoration-primary/6 page-api-block:ml-0"><div class="flex items-center justify-start [grid-area:1/1] text-sm gap-2">  
</div><button class="group-hover/codeblock:opacity-[1] transition-opacity duration-75 opacity-0 text-xs [grid-area:2/1] z-[2] justify-self-end backdrop-blur-md leading-none self-start ring-1 ring-dark/2 text-dark/7 bg-transparent rounded-md mr-2 mt-2 p-1 hover:ring-dark/3 dark:ring-light/2 dark:text-light/7 dark:hover:ring-light/3 print:hidden">Copy</button></div></div>```
docker pull portainer/agent:2.21.0
```

Finally, start the agent with the updated image:

<div class="[&>*+*]:mt-5 grid whitespace-pre-wrap" id="bkmrk-copy-6" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; box-sizing: border-box; border: 0px solid rgb(229, 231, 235); display: grid; white-space: pre-wrap; color: color(srgb 0.120353 0.120353 0.120353); font-family: __Inter_207ec3, __Inter_Fallback_207ec3, system-ui, arial; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: color(srgb 1 1 1); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="group/codeblock grid grid-flow-col max-w-3xl w-full mx-auto decoration-primary/6 page-api-block:ml-0"><div class="flex items-center justify-start [grid-area:1/1] text-sm gap-2">  
</div><button class="group-hover/codeblock:opacity-[1] transition-opacity duration-75 opacity-0 text-xs [grid-area:2/1] z-[2] justify-self-end backdrop-blur-md leading-none self-start ring-1 ring-dark/2 text-dark/7 bg-transparent rounded-md mr-2 mt-2 p-1 hover:ring-dark/3 dark:ring-light/2 dark:text-light/7 dark:hover:ring-light/3 print:hidden">Copy</button></div></div>```
docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes portainer/agent:2.21.0
```

<div class="[&>*+*]:mt-5 grid whitespace-pre-wrap" id="bkmrk--11" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; box-sizing: border-box; border: 0px solid rgb(229, 231, 235); display: grid; white-space: pre-wrap; color: color(srgb 0.120353 0.120353 0.120353); font-family: __Inter_207ec3, __Inter_Fallback_207ec3, system-ui, arial; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: color(srgb 1 1 1); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="group/codeblock grid grid-flow-col max-w-3xl w-full mx-auto decoration-primary/6 page-api-block:ml-0">  
</div><div class="px-4 py-4 transition-colors rounded-md straight-corners:rounded-none bg-gradient-to-b from-yellow/6 to-yellow/5 ring-1 ring-inset ring-dark/1 dark:ring-yellow/[0.02] dark:from-yellow/[0.06] dark:to-yellow/2 max-w-3xl w-full mx-auto decoration-primary/6 page-api-block:ml-0"><div class="flex flex-row"><div class="flex items-start justify-center pr-3 mt-0.5 leading-normal text-yellow-800 dark:text-yellow"><svg class="gb-icon size-4"></svg></div></div></div></div>If you have set a custom `AGENT_SECRET` on your Portainer Server instance (by specifying an `AGENT_SECRET` environment variable when starting the Portainer Server container) you must remember to explicitly provide the same secret to your Agent in the same way (as an environment variable) when updating your Agent:

`-e AGENT_SECRET=yoursecret`