Docker Community Forums

Share and learn in the Docker community.

Where is Docker installing the files?

Hello,
I’m trying to use a shell script (attached) to install an app in an Ubuntu box. Everything seems to initiate OK as about 0.6 GB are downloaded. However, I cannot locate any of the files that were supposed to be in the .elasticluster subdirectory (empty). This might be a very basic question but my guess is that the script might need some modification. Any hint or suggestion would be welcomed. Thanks.
P.S. Apparently new users cannot post attachments (script is 342 lines long) so I’m posting it as a preformatted text.

# put args back for elasticluster python to interpret
set -- $argv

# pull (update) Docker image
elasticluster_docker_image="${docker_image_name}:${docker_image_tag}"
if [ "$pull" = 'yes' ]; then
    docker pull "$elasticluster_docker_image"
fi

# cannot run as root, as mountpoints within the Docker image would be
# in the wrong place
if [ $(id -u) -eq 0 ]; then
    die $EX_SOFTWARE <<__EOF__
Cannot run as 'root' user: please run ElastiCluster with a normal,
unprivileged user.  (But ensure this user has permission to start
and access Docker containers; typically this means being part of
the 'docker' group.)
__EOF__
fi

# cannot run `sftp` in a Docker container
for arg in "$@"; do
    if [ "$arg" = 'sftp' ]; then
        die $EX_SOFTWARE <<__EOF__
ElastiCluster's 'sftp' command cannot be run in a Docker container.
Please see https://github.com/elasticluster/elasticluster/issues/576
for an explanation and possible workarounds.
__EOF__
    fi
done

# ensure mount points exist
for dir in "$HOME/.ssh" "$HOME/.elasticluster"; do
    test -d "$dir" || mkdir -v "$dir"
done

# prepare environment to export to Docker
# (necessary e.g. to preserve OpenStack auth)
envfile=$(mktemp -t elasticluster.XXXXXXXXXXXX.env)
if [ -z "$envfile" ]; then
    die 1 "Cannot create temporary file."
fi
trap "rm -f '$envfile';" EXIT INT QUIT ABRT TERM
if [ "$env_has_null_termination_opt" = 'y' ]; then
    # The following incantation requires some explanation:
    #
    # * line (1) `env` is to override some environment variables with
    #   values that are appropriate *within* the container;
    #
    # * line (2) is for filtering out multi-line env vars,
    #   which `docker run --env-file` cannot currently handle
    #   (see https://stackoverflow.com/a/19156442/459543 and
    #   issue #675 if the `awk` code looks overcomplicated);
    #
    # * line (3) `egrep -v` is for removing shell customization (e.g.,
    #   bash/zsh themes with multiline prompts)
    #
    env -0 HOME="$HOME"  SHELL=/bin/sh SSH_AUTH_SOCK=/home/.ssh-agent.sock \
        | awk 'BEGIN { RS="\0"; FS="="; OFS="="; }; { n=index($0, "="); $2=substr($0, n+1); NF=2; if ($2 !~ /\n/) print; };' \
        | egrep -v '^(BASH_ENV|ENV|PROMPT_COMMAND|PS[1234])=' \
                > "$envfile"
else
    env HOME="$HOME"  SHELL=/bin/sh SSH_AUTH_SOCK=/home/.ssh-agent.sock \
        | egrep -v '^(BASH_ENV|ENV|PROMPT_COMMAND|PS[1234])=' \
                > "$envfile"
fi

# go!
exec docker run --rm --interactive --tty --env-file "$envfile" $volumes $elasticluster_docker_image "$@"

I am not sure how “install an app in an Ubuntu box” correlatest with your script, which is a wrapper around a docker run command.

Docker run does not install anything. It will pull the used image (if it doesn’t exist in the local cache yet) and creates a container from it. Since you use --rm the container will be deleted when the container is stopped. Generaly docker stores it’s data in /var/lib/docker (unless it’s configured differently in /etc/docker/daemon.json)

Anyway, the objective of your question is completly unclear. What are you trying to achive?

Hi Metin,
The objective is simply to be able to run the app pulled by Docker. However, I cannot locate the executable (and modify the PATH accordingly) so my guess is that the files are within the Docker container. Obviously, I’m not that familiar with Docker syntax but checked the subdirectory that you mention. It simply reads:

ubuntu@ip-172-31-64-105:/var/lib/docker$ sudo ls -la
total 56
drwx–x--x 14 root root 4096 Aug 8 13:49 .
drwxr-xr-x 39 root root 4096 Aug 8 13:49 …
drwx------ 2 root root 4096 Aug 8 13:49 builder
drwx–x--x 4 root root 4096 Aug 8 13:49 buildkit
drwx------ 2 root root 4096 Aug 8 13:51 containers
drwx------ 3 root root 4096 Aug 8 13:49 image
drwxr-x— 3 root root 4096 Aug 8 13:49 network
drwx------ 11 root root 4096 Aug 8 13:51 overlay2
drwx------ 4 root root 4096 Aug 8 13:49 plugins
drwx------ 2 root root 4096 Aug 8 13:49 runtimes
drwx------ 2 root root 4096 Aug 8 13:49 swarm
drwx------ 2 root root 4096 Aug 8 13:51 tmp
drwx------ 2 root root 4096 Aug 8 13:49 trust
drwx------ 2 root root 4096 Aug 8 13:49 volumes

It feels that I’m missing something but not sure what.
Thanks.

Well, docker does not pull an app. It pulls an image which packages entrypoint scripts, the main app and all its depdencies. You already start a container from the pulled image: exec docker run --rm --interactive --tty --env-file "$envfile" $volumes $elasticluster_docker_image "$@"

Of couse they are in the container! Would anything else even make sense? Remember: a container is self contained - as such everything required to run the container must be inside the container…

Honestly, I am still unclear on what you try to do.

The goal is simply to run the app. The assumption is that calling the script starts the container (I think that we agree on this). However, when I invoke the command to start the app (here I am just following the instructions of the 3rd party developer), the OS simply doesn’t find the command. That is what I need to do: run the app installed inside the container. Thanks.

So basicly you are asking where files inside a container are located, even though you neither specified which image actualy is used (if pulled from DockerHub), nor share the Dockerfile used to create the image itself. Did I get that right?

If you are looking to broaden your understand for docker, I can highly recommend this excellent self paced training. Don’t be affraid of the number of slides - most of them can be read and understood in seconds.