Skip to content
This repository was archived by the owner on Nov 5, 2022. It is now read-only.

Commit d21c694

Browse files
committed
Merge pull request #1 from appropriate/safeguard
Adjust entrypoint to always warn on missing socket
2 parents 1aac996 + f95ff82 commit d21c694

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ ENV DOCKER_HOST unix:///tmp/docker.sock
3131
VOLUME ["/etc/nginx/certs"]
3232

3333
ENTRYPOINT ["/app/docker-entrypoint.sh"]
34-
CMD ["nginx-proxy"]
34+
CMD ["forego", "start", "-r"]

docker-entrypoint.sh

100644100755
Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
#!/bin/bash
22
set -e
33

4-
check_unix_socket() {
5-
if [[ $DOCKER_HOST == unix://* ]]; then
6-
socket_file=${DOCKER_HOST#unix://}
7-
if ! [ -S $socket_file ]; then
8-
cat >&2 <<-EOT
9-
ERROR: you need to share your docker host socket with a volume at $socket_file
10-
Typically you should run your jwilder/nginx-proxy with: \`-v /var/run/docker.sock:$socket_file:ro\`
11-
See documentation at http://git.io/vZaGJ
12-
EOT
13-
exit 1
14-
fi
4+
# Warn if the DOCKER_HOST socket does not exist
5+
if [[ $DOCKER_HOST == unix://* ]]; then
6+
socket_file=${DOCKER_HOST#unix://}
7+
if ! [ -S $socket_file ]; then
8+
cat >&2 <<-EOT
9+
ERROR: you need to share your Docker host socket with a volume at $socket_file
10+
Typically you should run your jwilder/nginx-proxy with: \`-v /var/run/docker.sock:$socket_file:ro\`
11+
See the documentation at http://git.io/vZaGJ
12+
EOT
13+
socketMissing=1
1514
fi
16-
}
17-
18-
################################################################################
15+
fi
1916

20-
# check for the expected command
21-
if [ "$1" = 'nginx-proxy' ]; then
22-
check_unix_socket
23-
exec forego start -r
17+
# If the user has run the default command and the socket doesn't exist, fail
18+
if [ "$socketMissing" = 1 -a "$1" = forego -a "$2" = start -a "$3" = '-r' ]; then
19+
exit 1
2420
fi
2521

26-
# else default to run whatever the user wanted like "bash"
2722
exec "$@"
28-
29-

0 commit comments

Comments
 (0)