The Problem
When I start a new container in Docker, I want to mount a volume so that I get the latest updates to any files on my host machine and can work with them in my container. However, what I am finding is that Docker is mounting my volumes when I build the image. What I want instead is to mount the volumes when I create a new container.
Because I am using Docker to manage my development environment, this means that whenever I update a little piece of code, I have to rebuild my development environment Docker image, which takes usually around 20-30 mins. Obviously, this is not the functionality I want from Docker.
Here is what I am using to build my development environment container:
Dockerfile
# This docker file constructs an Ubuntu development environment and configures the compiler/libs needed
FROM ubuntu:latest
ADD . /gdms-rcon/liaison
WORKDIR /gdms-rcon/liaison
RUN rm -rf ./build
RUN apt-get update
RUN apt-get install -y -f gcc g++ qtbase5-dev cmake mysql-client
fig.yml
liaison:
build: ./liaison/
command: /bin/bash
volumes:
- liaison:/gdms-rcon/liaison
working_dir: /gdms-rcon/liaison
I also use a fig.yml
file to make it easier to build.
To run, I use: fig build
To access my container to compile my source code, I use: docker run -it <container_id>
Maybe I'm doing something wrong with my commands? I don't use fig up
because it won't give me an interactive shell, so I use docker run -it <container_id>
instead. I chose to use fig
so that it would mount my volumes automatically, but it isn't working as I would have hoped.