Docker Community Forums

Share and learn in the Docker community.

New to docker - a few questions?


(Twigz) #1

I think I’m starting to understand the concepts around docker, but I’m still a little fuzzy.

Q1.
Volumes are used to persist data, and I see that you create them as such:

   Services:
    example_database:
       volumes:
          - ./database/data:/var/lib/mysql

What is the first part in this ("./database/data") and the second part (":/var/lib/myswl") doing exactly? Is the first part retrieving data from the local computer and storing it in the docker environment (“var/lib/mysql”)?

Q2.
I have a mysql server running via MAMP on port 8889. I’d like to connect to that mysql server within my docker container, but I’m not having any luck doing this via docker-compose.yml. It seems like the only way to get “use” this database would be to back it up, and load it in a mysql container. But I imagine there has to be a way to do this. Can anyone give me some clues?

Q3.
I’m finding examples of running a container that are purely command line. For example:

  docker run -tid -v $(pwd):/code -p 3306:3306 -p 5000:5000 \

However, I’d like to stick to using docker-compose, but I haven’t been able to find command line to compose translations. In fact, it doesn’t seem compose is nearly as powerful as the command line for building containers. Is this right or is there any documentation for translating?

Any help would be appreciated.

Thanks