Search code examples
dockernginxdockerfiledevopsdocker-swarm

Access to the nginx files from the broken Docker image


How can I extract the data from the nginx.conf and default.conf files if the image does not run. I tried with volumes but it shows that the file is empty.The image is this obur5/nginx-broken-image:latest

When I run image

Ween I open the files through docker desktop

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration

/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/

/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh

10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf

10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version

/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh

/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh

/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh

/docker-entrypoint.sh: Configuration complete; ready for start up

2023/11/13 07:52:40 [emerg] 1#1: no "events" section in configuration

nginx: [emerg] no "events" section in configuration

Solution

  • To extract the files from a docker image you can do something like this:

    docker cp $(docker container create <image>):/ rootfs
    

    This should extract the entire filesystem into a folder called "rootfs"