question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

docker-py cannot bind local files into a container?

See original GitHub issue

hi,all! I ofen bind host files into containers by using “-v /path/to/host/file:/container/file:ro”, when I using command line client. But now, I need to use docker-py to manage my containers. And I also need to do the same work:bind some host files into containers. And my code is like this (for example)


......
"volumes":["/etc/localtime"],
......
"binds":{
        "/etc/localtime":{
                 "bind":"/etc/localtime",
                 "ro":true
        }
},

unfortunately, problem emerged: APIError: 500 Server Error: Internal Server Error ( “Cannot start container 1c1…d7051: setup mount namespace mounting /var/lib/docker/vfs/dir/575…9f73 into /var/lib/docker/devicemapper/mnt/1c1f7f…1edd7051/rootfs/etc/localtime not a directory”)

what is the solution?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:20 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Brett55commented, Sep 12, 2017

if host_config was deprecated in 1.2.3, where do I pass in binds now?

1reaction
shin-commented, Apr 23, 2015

I think I’ve found the issue: can you try specifying the binds in the create_container call, like such

c.create_container(
    img, cmd, volumes=volumes, 
    host_config=docker.utils.create_host_config(binds=binds)
)

And see if that works?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bind mounts - Docker Documentation
Bind mounts have limited functionality compared to volumes. When you use a bind mount, a file or directory on the host machine is...
Read more >
Cannot bind mount a file that already exists in the container #5
C:\Users\m\src\phr\docker\local [develop ≡]> docker run -it -v ... Cannot bind mount a file that already exists in the container #5.
Read more >
How can I use a local file on container? - Stack Overflow
Docker Machine tries to auto-share your /Users (macOS) or C:\Users (Windows) directory. So, you can mount files or directories on macOS using. ...
Read more >
Docker is not updating the mounted file - Medium
The short explanation to this would be that Docker container single file bind mount strictly depends on the inode number.
Read more >
Add local file mount to a container - Visual Studio Code
You can add a volume bound to any local folder by using the following appropriate steps, based on what you reference in devcontainer.json...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found