Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I can't see my files inside a docker container?

I'm a Docker newbie and I'm trying to setup my first project. To test how to play with it, I just cloned one ready-to-go project and I setup it (Project repo). As the guide claims if I access a specific url, I reach the homepage. To be more specific a symfony start page.

Moreover with this command

docker run -i -t testdocker_application /bin/bash

I'm able to login to the container.

My problem is if I try to go to the application folder through bash, the folder that I shared with my host is empty.

I tried with another project, but the result is the same.

Where I'm wrong?

Here some infos about my env:

  • Ubuntu 12.04
  • Docker version 1.8.3, build f4bf5c7

Config:

application:
    build: code
    volumes:
        - ./symfony:/var/www/symfony
        - ./logs/symfony:/var/www/symfony/app/logs
    tty: true
like image 680
stuzzo Avatar asked Oct 15 '15 17:10

stuzzo


People also ask

How do I see files inside a docker container?

In the latest versions of Docker, something like this is possible: docker exec <container> bash . So, you just open a shell inside the container. Similarly, you can do: docker exec <container> ls <dir path> and docker exec <container> cat <file path> . For bash however, add the -it options.

Can I see the files inside a docker image?

To analyze a Docker image, simply run dive command with Docker "Image ID". You can get your Docker images' IDs using "sudo docker images" command. Here, ea4c82dcd15a is Docker image id. The Dive command will quickly analyze the given Docker image and display its contents in the Terminal.

Where are files in docker container stored?

Docker also supports containers storing files in-memory on the host machine. Such files are not persisted. If you're running Docker on Linux, tmpfs mount is used to store files in the host's system memory. If you're running Docker on Windows, named pipe is used to store files in the host's system memory.


1 Answers

Looks like you have a docker-compose.yml file but are running the image with docker. You don't actually need docker-compose to start a single container. If you just want to start the container your command should look like this:

docker run -ti -v $(pwd)/symfony:/var/www/symfony -v $(pwd)/logs/symfony:/var/www/symfony/app/logs testdocker_application /bin/bash

To use your docker-compose.yml start your container with docker-compose up. You would also need to add the following to drop into a shell.

stdin_open: true
command: /bin/bash
like image 100
Adam B Avatar answered Oct 25 '22 18:10

Adam B