From 1ecac38af0e0da6223a00ad37d889084c66726fb Mon Sep 17 00:00:00 2001 From: Giovanni Baratta Date: Sun, 3 Mar 2024 16:32:36 +0000 Subject: [PATCH] chore: configure docker during startup instead of during image building The reason for this change is that /etc/resolv.conf is reset when the container is started, so the DNS configuration is lost. --- .devcontainer.json | 4 +++- .devcontainer/configure_docker.sh | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.devcontainer.json b/.devcontainer.json index b5ab6c3..c5d5b36 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -4,7 +4,9 @@ "onCreateCommand": { "install-dependencies": "/bin/bash ./.devcontainer/install_dependencies.sh || echo 'Failing to install dependencies'", "install-yarn": "/bin/bash ./.devcontainer/install_yarn.sh || echo 'Script install_yarn failed'", - "configure-jekyll": "/bin/bash ./.devcontainer/configure_jekyll.sh || echo 'Jekyll configuration failed'", + "configure-jekyll": "/bin/bash ./.devcontainer/configure_jekyll.sh || echo 'Jekyll configuration failed'" + }, + "postStartCommand": { "configure-docker": "/bin/bash ./.devcontainer/configure_docker.sh || echo 'Docker configuration failed'" }, "features": { diff --git a/.devcontainer/configure_docker.sh b/.devcontainer/configure_docker.sh index 09b0f8a..48b5322 100644 --- a/.devcontainer/configure_docker.sh +++ b/.devcontainer/configure_docker.sh @@ -1,6 +1,10 @@ #!/bin/bash -docker network create host-network +if ! docker network list | grep host-network ; then + docker network create host-network +else + echo "host-network already exists. Skipping creation." +fi # Forward DNS queries to CoreDNS original_content=$(cat /etc/resolv.conf)