Docker-alpine: Error When Developing

Created on 4 Jun 2015  路  12Comments  路  Source: gliderlabs/docker-alpine

It seems like when I mount a volume on top of my code, the files aren't properly changing. This seems to only happening when I'm using alpine, other images work great.

Here's the steps to reproduce.

Example Dockerfile:

FROM alpine:3.2
RUN apk add --update python git python-dev py-pip gcc libgcc musl-dev && \
    pip install --upgrade pip

WORKDIR /home
COPY requirements.txt /home/
RUN pip install -r requirements.txt
COPY . /home
CMD ["sh"]

Note most of the installs are not needed for this example, but I've needed them for a few python packages, so leaving for this example in case that's possible issue

This isn't being used, but just in case (and I do plan on using some packages)
./requirements.txt

yamlsettings==0.2.2

./test.py

print "1"
print "2"
print "3"

Build the image:

docker build  -f Dockerfile -t local/movie_tags:dev .

Run the image (with deving in mind):

docker run -it --rm -v $(pwd):/home local/movie_tags:dev

Within the docker container:

> python test.py
1
2
3

On my host system edit test.py and add a line with print "4" and then back in the container:

> python test.py
1
2
3
> cat test.py
print "1"
print "2"
print "3"
> vi test.py
print "1"
print "2"
print "3"
print "4"
> python test.py
1
2
3

It seems very odd that vi see the correct files, but the python and cat processes seem to have a link to the old file....

docker info:

Containers: 0
Images: 51
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 51
Execution Driver: native-0.2
Kernel Version: 3.18.5-tinycore64
Operating System: Boot2Docker 1.5.0 (TCL 5.4); master : a66bce5 - Tue Feb 10 23:31:27 UTC 2015
CPUs: 8
Total Memory: 1.961 GiB
Name: boot2docker
ID: OSTT:VV2Y:LHSF:2N46:KIDT:FZC5:JKNQ:O5KE:P5YW:A4DN:OWCM:O6P3
Debug mode (server): true
Debug mode (client): false
Fds: 11
Goroutines: 16
EventsListeners: 0
Init Path: /usr/local/bin/docker
Docker Root Dir: /mnt/sda1/var/lib/docker

boot2docker version

Boot2Docker-cli version: v1.5.0
Git commit: ccd9032

Also building and running without the mounting works great, but that won't work well while developing.

Please let me know if you've seen this issue, or if anyone can reproduce it Thanks.

Most helpful comment

OMG I'm so happy to find someone experiencing the same issue.
Still happening in 2017 with latest versions of everything. Really seems related to Alpine.

All 12 comments

Ok simpler steps:

docker run -it --rm -v /Users/kyle.walker/work/movie_tags:/home alpine sh

Then within the container run:

cat /home/test.py (seems to always be 1,2,3)
vi /home/test.py (follows the host filesystem correctly)

Can you try this test on the boot2docker host outside of /Users to eliminate the vboxsf folder share from the equation?

Host: mkdir /tmp/testing
Host: docker run -it -v /tmp/testing:/code alpine sh
Container: ls -al (nothing)
Host: touch /tmp/testing/file
Container: ls -al (nothing)

Same thing when using base image python:2.7, so something else must be going on with boot2docker? I haven't had any issues before, and when I first starting having issues I tried a boot2docker destroy boot2docker init to see if ti would help any.

Update that messes with stuff inside my boot2docker vm, let me test again while looking with boot2docker ssh.

While in the docker vm, editing seems to be ok, so it must be something to do with the vboxsf folder share.... Any ideas on what it might be?

Ok now I have no idea what was going on, I did a boot2docker delete and recreation, and it was fine for a couple edits, and now it's not. I'm about to throw away boot2docker and starting using vagrant again with the docker in there, at least that way there will be less black magic going on...

Still not sure why cat seems to error out but vi seems to always get the latest file. I'm wondering if there's some caching going on, do you know if there's a way to flush and drive cache?

Let me go back to the outside /Users again, since it looked good with one edit, but doing many borked it.

After destroying my VM, removing docker/boot2docker, re-installing, etc. I found out it seems to be an issue with vboxfs and annoying caching.

@andyshinn suggested it may have to do with how files are accessed differently between musl libc and glibc.

So I found a nice little script to flip my boot2docker to use nfs instead.

And just in case I made a copy of the script.

Leaving this issue open (feel free to close it), in case someone else has any other ideas, but nfs is good enough for me.

I haven't experienced this exact issue with VirtualBox, but have had other issues. NFS helps, but also isn't the ultimate solution. Another solution you might try that seemed to have the best support is Vagrant with the"auto Rsync" daemon. Though, these issues are not necessarily related to the Alpine image.

You can force docker-machine to use NFS: https://github.com/adlogix/docker-machine-nfs

I have encountered the same issue, alpine linux container doesn't see updates to the file(on vboxsf mount) modified outside of the container. I dont use boot-2-docker, The above solution to use NFS isn't going to help me.

I am rather going to try an use local fs instead of vboxsf, although i will have to dump the contents to shared folder before exiting the container each time.

OMG I'm so happy to find someone experiencing the same issue.
Still happening in 2017 with latest versions of everything. Really seems related to Alpine.

I am also experiencing the same issue. I'm using vagrant with an alpine-based container inside the vagrant VM. I thought I was losing my mind.

Was this page helpful?
0 / 5 - 0 ratings