# Docker

# Portainer API Setup

To allow Portainer to add an environment. Docker must be configured to open the port for remote access. The firewall must also allow this port. Below is for no TLS.

Edit:

```bash
nano /lib/systemd/system/docker.service
```

Add the line and comment out the other ExecStart line.

```bash
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
```

Reload systemctl after the change

```bash
systemctl daemon-reload
```

Add fire exception (RHEL)

```bash
firewall-cmd --zone=public --add-port=2375/tcp --permanent
firewall-cmd --reload
```

Restart the service

```bash
systemctl restart docker.service
```

# Portainer Enviroment Configuration

##### On the left side menu of Portainer click on the environment tab to add a new environment.   


[![Portainer-enviroments.png](https://kb.koryalbert.net/uploads/images/gallery/2023-06/scaled-1680-/portainer-enviroments.png)](http://bookstack.korys.lan/uploads/images/gallery/2023-06/portainer-enviroments.png)

##### Under Enviroment type click on Docker

[![Portainer-docker-01.png](https://kb.koryalbert.net/uploads/images/gallery/2023-06/scaled-1680-/portainer-docker-01.png)](http://bookstack.korys.lan/uploads/images/gallery/2023-06/portainer-docker-01.png)

##### Fill out the name and the "Environment URL" as follows

[![Portainer-docker-02.png](https://kb.koryalbert.net/uploads/images/gallery/2023-06/scaled-1680-/portainer-docker-02.png)](http://bookstack.korys.lan/uploads/images/gallery/2023-06/portainer-docker-02.png)

We are not using TLS on this, since it is not a production setup so we can skip it.