Dockerfile/etcd/Dockerfile

36 lines
1.5 KiB
Docker
Raw Normal View History

2019-01-30 06:05:57 +00:00
# https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/container.md#docker
FROM alpine:latest
2019-05-10 03:06:49 +00:00
ARG ETCD_VER=v3.3.13
2019-01-30 06:05:57 +00:00
ARG ETCD_DOWNLOAD_URL=https://github.com/coreos/etcd/releases/download
ENV DATA_DIR=/var/lib/etcd/
ENV IP=0.0.0.0
ENV NODE_NAME=node1
ENV CLUSTER=${NODE_NAME}=http://${IP}:2380
ENV TOKEN=my-etcd-token
ENV CLUSTER_STATE=new
2019-05-08 10:10:47 +00:00
ENV ETCDCTL_API=3
2019-01-30 06:05:57 +00:00
2019-05-10 03:06:49 +00:00
# VOLUME [ "${DATA_DIR}" ]
2019-01-30 06:05:57 +00:00
RUN wget ${ETCD_DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz \
&& tar -xzvf etcd*.tar.gz \
&& mv etcd*/etcd /usr/local/bin/ \
2019-05-08 10:10:47 +00:00
&& mv etcd*/etcdctl /usr/local/bin/ \
2019-01-30 06:05:57 +00:00
&& rm -rf etcd* \
&& mkdir -p ${DATA_DIR} \
# Alpine Linux doesn't use pam, which means that there is no /etc/nsswitch.conf,
# but Golang relies on /etc/nsswitch.conf to check the order of DNS resolving
# (see https://github.com/golang/go/commit/9dee7771f561cf6aee081c0af6658cc81fac3918)
# To fix this we just create /etc/nsswitch.conf and add the following line:
&& echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
EXPOSE 2379 2380
CMD ["sh", "-c", "etcd --data-dir ${DATA_DIR} --name ${NODE_NAME} \
--initial-advertise-peer-urls http://${IP}:2380 --listen-peer-urls http://${IP}:2380 \
--advertise-client-urls http://${IP}:2379 --listen-client-urls http://${IP}:2379 \
--initial-cluster ${CLUSTER} \
2019-05-08 10:10:47 +00:00
--initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN} \
--auto-compaction-retention=1"]