info@tijmenschoemaker.nl

Script i use for creating dockers on unix systems

I have create a script for personal use to easily create dockers with changing just a few parameters within the script.
Since i’m no Unix guru, this might be open for improvements.

I would call my 1st script, create_0_portainer.sh for example. It uses a own created bridge network so i can assign ip adressess.

If this needs an update, i would just run the script since data is persistent and it deletes and retrevies the image.


#!/usr/bin/env bash
dockername=portainer
dockernetwork=br_0
dockerimage="portainer/portainer"

docker stop $dockername
docker rm $dockername
docker rmi $dockerimage
docker create \
--name=$dockername \
--hostname=$dockername \
--net=$dockernetwork \
--ip=172.20.0.2 \
-p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /home/dockers/$dockername:/data \
$dockerimage
docker update --restart=always $dockername
docker start $dockername