Skip to content

Commit b7b808d

Browse files
authored
Merge pull request #899 from jc21/develop
Docs for a docker network
2 parents 4a8d012 + a21289b commit b7b808d

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

docs/advanced-config/README.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
# Advanced Configuration
22

3+
## Best Practice: Use a docker network
4+
5+
For those who have a few of their upstream services running in docker on the same docker
6+
host as NPM, here's a trick to secure things a bit better. By creating a custom docker network,
7+
you don't need to publish ports for your upstream services to all of the docker host's interfaces.
8+
9+
Create a network, ie "scoobydoo":
10+
11+
```bash
12+
docker network create scoobydoo
13+
```
14+
15+
Then add the following to the `docker-compose.yml` file for both NPM and any other
16+
services running on this docker host:
17+
18+
```yml
19+
networks:
20+
default:
21+
external:
22+
name: scoobydoo
23+
```
24+
25+
Let's look at a Portainer example:
26+
27+
```yml
28+
version: '3'
29+
services:
30+
31+
portainer:
32+
image: portainer/portainer
33+
privileged: true
34+
volumes:
35+
- './data:/data'
36+
- '/var/run/docker.sock:/var/run/docker.sock'
37+
restart: always
38+
39+
networks:
40+
default:
41+
external:
42+
name: scoobydoo
43+
```
44+
45+
Now in the NPM UI you can create a proxy host with `portainer` as the hostname,
46+
and port `9000` as the port. Even though this port isn't listed in the docker-compose
47+
file, it's "exposed" by the portainer docker image for you and not available on
48+
the docker host outside of this docker network. The service name is used as the
49+
hostname, so make sure your service names are unique when using the same network.
50+
351
## Docker Secrets
452

553
This image supports the use of Docker secrets to import from file and keep sensitive usernames or passwords from being passed or preserved in plaintext.
@@ -34,7 +82,7 @@ services:
3482
DB_MYSQL_PORT: 3306
3583
DB_MYSQL_USER: "npm"
3684
# DB_MYSQL_PASSWORD: "npm" # use secret instead
37-
DB_MYSQL_PASSWORD__FILE: /run/secrets/MYSQL_PWD
85+
DB_MYSQL_PASSWORD__FILE: /run/secrets/MYSQL_PWD
3886
DB_MYSQL_NAME: "npm"
3987
# If you would rather use Sqlite uncomment this
4088
# and remove all DB_MYSQL_* lines above
@@ -55,7 +103,7 @@ services:
55103
MYSQL_DATABASE: "npm"
56104
MYSQL_USER: "npm"
57105
# MYSQL_PASSWORD: "npm" # use secret instead
58-
MYSQL_PASSWORD__FILE: /run/secrets/MYSQL_PWD
106+
MYSQL_PASSWORD__FILE: /run/secrets/MYSQL_PWD
59107
volumes:
60108
- ./data/mysql:/var/lib/mysql
61109
```

0 commit comments

Comments
 (0)