This is a summary of many Docker setups. In each folder, there is an instruction to setup this docker configuration. Be aware that most containers work with traefik as a reverse proxy in front of it. For an easy setup and to tell traefik where to route the traffic we use traefik labels on each container and one network named "proxy" for all containers. We know that this isn't the securest way, but the most flexible and easiest way to implement.
sudo apt-get update && sudo apt-get upgrade -y
Docker provides a install script. Just run:
curl -sSL https://get.docker.com | sh
By default, only users who have administrative privileges (root users) can run containers. You could also add your non-root user to the Docker group which will allow it to execute docker commands.
To add the current user to the Docker group run:
sudo usermod -aG docker ${USER}
Reboot the server to let the changes take effect.
Docker-Compose usually gets installed using pip3. For that, we need to have python3 and pip3 installed.
sudo apt-get install libffi-dev libssl-dev -y
sudo apt install python3-dev -y
sudo apt-get install python3 python3-pip -y
Now we can install Docker-Compose.
sudo pip3 install docker-compose
You can configure your server to automatically run the Docker system service, whenever it boots up.
sudo systemctl enable docker
Edit or create this file: sudo nano /etc/docker/daemon.json
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8:1::/64",
"experimental": true,
"ip6tables": true
}
Now restart docker with: sudo service docker restart
To test IPv4 and IPv6 you can use thw whoami container (which is in the proxy/docker-compose.yaml file) without a password protection (no Authelia) and open this webside through this one below:
For an easy start of the containers, there is a script with which you can start and stop all of them or only chosen stacks. A stack is a combination of multiple containers which are all in one folder/docker-compose.yml file.
Example:
./docker.sh -h
./docker.sh -l
./docker.sh -c [StackName]
./docker.sh -S [StackName] -r
./docker.sh -S [StackName] -s
./docker.sh -r
./docker.sh -s
.
├── StackName1
│ ├── build (optional)
│ │ └── dockerfile (optional)
│ ├── data (folder)
│ ├── data.tmpl (folder)
│ ├── docker-compose.yml (optional)
│ ├── .env.tmpl (optional)
│ ├── .env
│ ├── .gitignore
│ └── README.md
│
├── StackName2
│ ├── ...
│ ...
│
├── .gitignore
├── .stackignore
├── docker.sh
├── global.env
├── global.env.temp
└── README.md
If there is no data
folder, the data.tmpl
folder will be copied (data.tmpl
->data
). The same will be done for the .env.tmpl
file (.env.tmpl
->.env
).
Suppose you create a new stack with docker.sh -c [StackName]
the docker-compose.tmpl.yml
file from the root folder will be copied to the newly created stack.
If you run ./docker.sh -r
or ./docker.sh -s
the script will look into each folder in this directory and look for a file named docker-composed.yml
. If it exists it will deploy this stack. If you want to ignore a folder you have to write the name of the folder in the .stackignore
file. It works similarly to the .gitignore file.
Example:
nextcloud
onedrive
#portainer
#traefik
webtop
When you now run ./docker.sh -r
or ./docker.sh -s
all the stacks will start/stop except nextcloud
, onedrive
and webtop
Every time you run docker.sh
it will check that all the environment variables in the global.env
file are present in each .env
file in each folder in this directory. The .stackignore
file doesn't have any impact on this function. This means it will update also the .env
file even if this stack is in the .stackignore
file. If you delete or update a variable from the global.env
file, it will detect this and will remove it from each .env
file.
Example:
Domain='example.com'
ServerIPv4='123.456.789.123'
ServerIPv6='abcd:efgh:123:456:789:0000:0000:0001'
TimeZone='Europe/Berlin'
- Pls use the
docker.sh
script to generate new stacks. It will automaticly create a new stack with the following structure (example):. ├── example │ ├── build (optional) │ │ └── dockerfile (optional) │ ├── data (folder) │ ├── docker-compose.yml │ ├── .env │ ├── .gitignore │ └── README.md │ ...
- If you need a
Dockerfile
to build your own container pls manually add a folder namedbuild
with theDockerfile
inside (optional).
- If you need a
- In each folder there should be a README with setup instructions about this stack.
- For clean and nice emojis in the git commits pls have a look at gitmoji.dev
- Feel free to extend the docker collection :D