The problem: My docker-compose script can't connect to the outbound internet. Currently i am on a Ubuntu 22.04.2 System. On my other server Ubuntu 20 the same script works. Therefore my configuration for docker must be wrong.
In my docker-compose script i want to create with letsencrypt a new certificate but when communicating with letsencrypt i get errors.
Running budybox with ping:
docker run --rm -it busybox ping -c 3 acme-v02.api.letsencrypt.org
Results in:
ping: bad address 'acme-v02.api.letsencrypt.org'
But when i run in network host it works:
docker run --rm -it --network host busybox ping -c 3 acme-v02.api.letsencrypt.org
Result:
PING acme-v02.api.letsencrypt.org (172.65.32.248): 56 data bytes
64 bytes from 172.65.32.248: seq=0 ttl=58 time=0.859 ms
64 bytes from 172.65.32.248: seq=1 ttl=58 time=1.745 ms
^C
--- acme-v02.api.letsencrypt.org ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
This is my docker-compose.yaml file:
version: '3'
services:
outer:
container_name: outer
env_file: .env
build: .
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
ports:
- "80:80"
- "443:443"
restart: always
environment:
- DEFAULT_HOST=${MYHOST}
- DHPARAM_GENERATION=false
logging:
driver: local #or "none" or "local"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro # allow to read running dockers
- ./extraVolumes/certs:/etc/nginx/certs:rw
- ./extraVolumes/vhosts:/etc/nginx/vhost.d:rw
- ./extraVolumes/html:/usr/share/nginx/html:rw
networks:
- reverse-proxy
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
env_file: .env
environment:
### ToDo: Change to your e-mail address
- DEFAULT_EMAIL=${EMAIL}
- NGINX_PROXY_CONTAINER=outer
volumes_from:
- outer
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./extraVolumes/certs:/etc/nginx/certs:rw
- ./extraVolumes/vhosts:/etc/nginx/vhost.d:rw
- ./acme:/etc/acme.sh
restart: always
networks:
- reverse-proxy
app:
container_name: outer_app
image: jwilder/whoami
env_file: .env
environment:
- VIRTUAL_HOST=${MYHOST}
- LETSENCRYPT_HOST=${MYHOST}
- VIRTUAL_PATH=/ping/
- VIRTUAL_DEST=/
networks:
- reverse-proxy
redirect:
image: morbz/docker-web-redirect
env_file: .env
restart: always
environment:
- VIRTUAL_HOST=${MYHOST}
- VIRTUAL_PATH=/
- VIRTUAL_DEST=/
- REDIRECT_TARGET=${MYHOST}/homepage/ # Just /homepage without ending with a / will result in infinite redirects
# For more see: https://serverfault.com/questions/821997/nginx-reverse-proxy-too-many-redirections
# Also the - VIRTUAL_PATH=/ping/ must end with a / too
networks:
- reverse-proxy
redirect_catch:
container_name: redirect_catch
image: jwilder/whoami
env_file: .env
environment:
- VIRTUAL_HOST=${MYHOST}
- LETSENCRYPT_HOST=${MYHOST}
- VIRTUAL_PATH=/homepage/homepage/
- VIRTUAL_DEST=/
networks:
- reverse-proxy
networks:
reverse-proxy:
name: topDomainProxy
I configured my .env accordingly, replaced values with OMITED.
MYHOST=OMITED
EMAIL=OMITED
PATH_TO_CERT=./
PATH_TO_KEY=./
When running my compose file:
letsencrypt_1 | [Wed Jun 14 20:15:07 UTC 2023] Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: 7
letsencrypt_1 | [Wed Jun 14 20:15:07 UTC 2023] Can not init api for: https://acme-v02.api.letsencrypt.org/directory.
letsencrypt_1 | [Wed Jun 14 20:15:08 UTC 2023] Registering account: https://acme-v02.api.letsencrypt.org/directory
letsencrypt_1 | [Wed Jun 14 20:15:11 UTC 2023] Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: 7
letsencrypt_1 | [Wed Jun 14 20:15:11 UTC 2023] Could not get nonce, let's try again.
What can i do, where is my problem? I cant change my Ubuntu...
I already tried:
- reinstalling docker
- ip forward
- daemon.json to configure
- and a lot of other stack overflow answers.
Already tried: No internet connection inside Docker containers