mam poniżej Dockerfile do konfiguracji Heca i zbudowałem Döcker zdjęcie, któreniepoprawny nagłówek podczas biegu Döcker obraz
FROM openjdk:8-jre-alpine
# Install required packages
RUN apk add --no-cache \
bash \
su-exec
ENV ZOO_USER=zookeeper \
ZOO_CONF_DIR=/conf \
ZOO_DATA_DIR=/data \
ZOO_DATA_LOG_DIR=/datalog \
ZOO_PORT=2181 \
ZOO_TICK_TIME=2000 \
ZOO_INIT_LIMIT=5 \
ZOO_SYNC_LIMIT=2
# Add a user and make dirs
RUN set -x \
&& adduser -D "$ZOO_USER" \
&& mkdir -p "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_CONF_DIR" \
&& chown "$ZOO_USER:$ZOO_USER" "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_CONF_DIR"
ARG GPG_KEY=C823E3E5B12AF29C67F81976F5CECB3CB5E9BD2D
ARG DISTRO_NAME=zookeeper-3.4.9
# Download Apache Zookeeper, verify its PGP signature, untar and clean up
RUN set -x \
&& apk add --no-cache --virtual .build-deps \
gnupg \
&& wget -q "http://www.apache.org/dist/zookeeper/$DISTRO_NAME/$DISTRO_NAME.tar.gz" \
&& wget -q "http://www.apache.org/dist/zookeeper/$DISTRO_NAME/$DISTRO_NAME.tar.gz.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-key "$GPG_KEY" \
&& gpg --batch --verify "$DISTRO_NAME.tar.gz.asc" "$DISTRO_NAME.tar.gz" \
&& tar -xzf "$DISTRO_NAME.tar.gz" \
&& mv "$DISTRO_NAME/conf/"* "$ZOO_CONF_DIR" \
&& rm -r "$GNUPGHOME" "$DISTRO_NAME.tar.gz" "$DISTRO_NAME.tar.gz.asc" \
&& apk del .build-deps
WORKDIR $DISTRO_NAME
VOLUME ["$ZOO_DATA_DIR", "$ZOO_DATA_LOG_DIR"]
EXPOSE $ZOO_PORT 2888 3888
ENV PATH=$PATH:/$DISTRO_NAME/bin \
ZOOCFGDIR=$ZOO_CONF_DIR
COPY docker-entrypoint.sh/
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["zkServer.sh", "start-foreground"]
zbudować go tak:
[email protected]:/home/david/zookeeper-docker# docker build -t david/zookeeper:3.4.9 .
Kiedy uruchomić instancję Heca, otrzymuję ten błąd:
[email protected]:/home/david/zookeeper-docker# docker run --name zookeeper --restart always -d david/zookeeper:3.4.9
24a282f2d04f1b638820a63a2037f618621d315d8c1cdb62aed609426bb19045
docker: Error response from daemon: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"exec: \\\"/docker-entrypoint.sh\\\": permission denied\"\n".
Co jest nie tak tutaj mam wszystkie moje pliki nie? w katalogu zookeeper-docker
. Podałem także chmod +x
persmission do docker-entrypoint.sh
w moim bieżącym katalogu.
Poniżej znajduje się treść docker-entrypoint.sh
#!/bin/bash
set -e
# Allow the container to be started with `--user`
if [ "$1" = 'zkServer.sh' -a "$(id -u)" = '0' ]; then
chown -R "$ZOO_USER" "$ZOO_DATA_DIR" "$ZOO_DATA_LOG_DIR"
exec su-exec "$ZOO_USER" "$0" "[email protected]"
fi
# Generate the config only if it doesn't exist
if [ ! -f "$ZOO_CONF_DIR/zoo.cfg" ]; then
CONFIG="$ZOO_CONF_DIR/zoo.cfg"
echo "clientPort=$ZOO_PORT" >> "$CONFIG"
echo "dataDir=$ZOO_DATA_DIR" >> "$CONFIG"
echo "dataLogDir=$ZOO_DATA_LOG_DIR" >> "$CONFIG"
echo "tickTime=$ZOO_TICK_TIME" >> "$CONFIG"
echo "initLimit=$ZOO_INIT_LIMIT" >> "$CONFIG"
echo "syncLimit=$ZOO_SYNC_LIMIT" >> "$CONFIG"
for server in $ZOO_SERVERS; do
echo "$server" >> "$CONFIG"
done
fi
# Write myid only if it doesn't exist
if [ ! -f "$ZOO_DATA_DIR/myid" ]; then
echo "${ZOO_MY_ID:-1}" > "$ZOO_DATA_DIR/myid"
fi
exec "[email protected]"
Poniżej jest wyjście:
[email protected]:/home/david/zookeeper-docker# docker run --name zookeeper --entrypoint "/usr/bin/env" david/zookeeper:3.4.9 -- ls -al/
total 80
drwxr-xr-x 47 root root 4096 Nov 7 19:09 .
drwxr-xr-x 47 root root 4096 Nov 7 19:09 ..
-rwxr-xr-x 1 root root 0 Nov 7 19:09 .dockerenv
drwxr-xr-x 2 root root 4096 Nov 7 17:44 bin
drwxr-xr-x 2 zookeepe zookeepe 4096 Nov 7 17:45 conf
drwxr-xr-x 2 zookeepe zookeepe 4096 Nov 7 19:09 data
drwxr-xr-x 2 zookeepe zookeepe 4096 Nov 7 19:09 datalog
drwxr-xr-x 5 root root 360 Nov 7 19:09 dev
-rw-r--r-- 1 root root 873 Nov 6 01:36 docker-entrypoint.sh
drwxr-xr-x 22 root root 4096 Nov 7 19:09 etc
drwxr-xr-x 3 root root 4096 Nov 7 17:44 home
drwxr-xr-x 8 root root 4096 Nov 7 17:45 lib
lrwxrwxrwx 1 root root 12 Oct 18 18:58 linuxrc -> /bin/busybox
drwxr-xr-x 5 root root 4096 Oct 18 18:58 media
drwxr-xr-x 2 root root 4096 Oct 18 18:58 mnt
dr-xr-xr-x 141 root root 0 Nov 7 19:09 proc
drwx------ 2 root root 4096 Oct 18 18:58 root
drwxr-xr-x 2 root root 4096 Oct 18 18:58 run
drwxr-xr-x 2 root root 4096 Nov 7 17:44 sbin
drwxr-xr-x 2 root root 4096 Oct 18 18:58 srv
dr-xr-xr-x 13 root root 0 Nov 7 19:09 sys
drwxrwxrwt 2 root root 4096 Nov 7 17:45 tmp
drwxr-xr-x 19 root root 4096 Nov 7 17:45 usr
drwxr-xr-x 15 root root 4096 Nov 7 17:44 var
drwxr-xr-x 10 1001 1001 4096 Nov 7 17:45 zookeeper-3.4.9
Co jest w środku 'docker-entrypoint.sh'? – R0MANARMY
Zaktualizowałem w pytaniu. – john
Zaktualizowałem ponownie. daj mi znać, jeśli to masz na myśli. Jestem stosunkowo nowy w Docker, więc daj mi znać, jeśli nie robię nic dobrze. – john