~/D/dockerfiles/redis-alpine $ tree
.
├── DockerHelper.mk
└── Makefile
0 directories, 2 files
~/D/dockerfiles/redis-alpine $ cat Makefile
-include DockerHelper.mk
NAME := redis
IMAGE := redis:alpine
NET_OPTIONS := --driver=bridge
RUN_COMMAND := redis-server --appendonly yes
RUN_OPTIONS := \
--detach=true \
--env=TZ=Europe/Kiev \
--network=backend \
--restart=unless-stopped \
--user=$(shell id -u):$(shell id -g) \
--volume="$(HOME)/.redis":/data
# create directory before run if not exist
pre-run::
test -d "${HOME}/.redis" || mkdir -p "${HOME}/.redis"
~/D/dockerfiles/redis-alpine $ make run
test -d "/home/sergei/.redis" || mkdir -p "/home/sergei/.redis"
docker run --detach=true --env=TZ=Europe/Kiev --network=backend --restart=unless-stopped --user=65534:65534 --volume=""/home/sergei/.redis"":/data --name redis redis:alpine redis-server --appendonly yes
Unable to find image 'redis:alpine' locally
alpine: Pulling from library/redis
9d48c3bd43c5: Already exists
6bcae78f4e99: Pull complete
8cb2d2938e96: Pull complete
8144cfccc349: Pull complete
4ff1d177b4d1: Pull complete
a67c684f8341: Pull complete
Digest: sha256:50899ea1ceed33fa03232f3ac57578a424faa1742c1ac9c7a7bdb95cdf19b858
Status: Downloaded newer image for redis:alpine
801ebd96137799a8473d94445758f36c889bb6c90846dc3857c18dea9536edce
~/D/dockerfiles/redis-alpine $ make ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
801ebd961377 redis:alpine "docker-entrypoint.s…" 1 minutes ago Up 1 minutes 6379/tcp redis
~/D/dockerfiles/redis-alpine $ make networks
NETWORK ID NAME DRIVER SCOPE
ecdc7a1d27c3 backend bridge local
~/D/dockerfiles/transmission $ tree
.
├── Dockerfile
├── DockerHelper.mk
├── Makefile
└── transmission.settings.json
0 directories, 4 files
~/D/dockerfiles/transmission $ cat Dockerfile
FROM alpine:latest
LABEL maintainer "SmartFinn (https://github.com/SmartFinn)"
ENV TRANSMISSION_HOME=/config \
HOME=/config
RUN apk --no-cache add transmission-daemon \
&& test -d /config || mkdir -p /config \
&& chown -R transmission:nobody /config /media
COPY transmission.settings.json /config/settings.json
EXPOSE 9091
USER transmission
VOLUME ["/config", "/media"]
ENTRYPOINT ["transmission-daemon"]
CMD ["--foreground", "--log-error"]
~/D/dockerfiles/transmission $ cat Makefile
-include DockerHelper.mk
IMAGE := transmission
RUN_OPTIONS := \
--detach=true \
--publish=9091:9091 \
--restart=unless-stopped \
--blkio-weight=400 \
--cpu-shares=512 \
--user=$(shell id -u):$(shell id -g) \
--volume=/etc/localtime:/etc/localtime:ro \
--volume=$(HOME)/.transmission:/config \
--volume=/media:/media
# create directory if not exist and copy the config
pre-run::
test -d "${HOME}/.transmission" || mkdir -p "${HOME}/.transmission"
test -f "${HOME}/.transmission/settings.json" \
|| cp transmission.settings.json "${HOME}/.transmission/settings.json")
~/D/dockerfiles/transmission $ make build
docker build --force-rm --tag transmission:latest /home/sergei/Development/dockerfiles/transmission
Sending build context to Docker daemon 10.24kB
Step 1/10 : FROM alpine:latest
---> 961769676411
[ ... ]
Step 10/10 : CMD ["--foreground", "--log-error"]
---> Running in ffddb75c296e
Removing intermediate container ffddb75c296e
---> 1c97ff194f17
Successfully built 1c97ff194f17
Successfully tagged transmission:latest
~/D/dockerfiles/transmission $ make ls
REPOSITORY TAG IMAGE ID CREATED SIZE
transmission latest 1c97ff194f17 About a minute ago 8.63MB
~/D/dockerfiles/transmission $ make run
test -d "/home/sergei/.transmission" || mkdir -p "/home/sergei/.transmission"
test -f "/home/sergei/.transmission/settings.json" || cp transmission.settings.json "/home/sergei/.transmission/settings.json"
docker run --detach=true --publish=9091:9091 --restart=unless-stopped --blkio-weight=400 --cpu-shares=512 --user=1000:1000 --volume=/etc/localtime:/etc/localtime:ro --volume=/home/sergei/.transmission:/config --volume=/media:/media --name transmission transmission:latest
40d9dc1b482fa9fbe487ac9af1f1b21be3827c312a7c9a16517afe26fb1676f1
~/D/dockerfiles/transmission $ make ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
40d9dc1b482f transmission:latest "transmission-daemon…" About a minute ago Up About a minute 0.0.0.0:9091->9091/tcp transmission
~/D/dockerfiles/transmission $ make destroy
---> stop container 'transmission'
---> remove container 'transmission
~/D/dockerfiles/transmission $ make rmi
---> Untagged: transmission:latest
---> Deleted: sha256:1c97ff194f17c19b48119da2a5d0309e241a02855304a865e5c519ee9991c382
---> Deleted: sha256:5528b39d926446121fe27c25bc2f3ee83b9e770914b06d0d099b8de10afe3e25
---> Deleted: sha256:c573d330813332267d9506f50865c8584aa2e25e81eb5e7b99a81ead8bbdf558
---> Deleted: sha256:b4246ad27ae313f76415d7948961395d4cf4d5b7912fa867db068f41be7203c1
---> Deleted: sha256:527771c6a2fecf4109d7142eebab201d099a30c43c0f15d955b37f0834766ac0
---> Deleted: sha256:cf0fe6c9500b061566f5d868049c5044a06fb2adf15ecf208ea4f3e00dabcd0e
---> Deleted: sha256:66f823940fee9b30213aef3eb76ca1644df6f54a0f9fd4b6d912ba6eedfccaaf
---> Deleted: sha256:1c6b8e09583cfac98712ca7a6fa592ca21168617acf2c732d6ea5fe96062edef
---> Deleted: sha256:b8818a84d03d8466e63deed56d53c65670a53743c3838aaee65bc5bb1f242cd2
---> Deleted: sha256:6db46b590a7b93787e58453af8c0a70968b6c0c7fe54b624b9fe7b5d5deb1f9a
More examples https://github.com/SmartFinn/Dockerfiles