docker / docker/docker-py

Unexpected mounted volumes

Open
#2,833 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

Hello,

I am having issue mounting repository into a container. I actually want to mount the the current working directory, where my python script is called, to the working directory of the my container. However, I ends up with different files.

import os
import docker

os.listdir(os.getcwd())
['run_analytic_to_benchmark.ipynb', 'run_analytic_to_benchmark.py', '.ipynb_checkpoints', 'test_.geojson']

docker_client = docker.from_env()
volumes_ = {os.getcwd(): {'bind': '/workspace/test', 'mode': 'rw'}}
docker_client.containers.run("ubuntu", "ls", volumes=volumes_, working_dir="/workspace/test", auto_remove=True)
b'sat_data\nvector_file.geojson\n'

I would expect the ls command from the container to return the same files list as the os.listdir(os.getcwd())..

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the posted Python example using docker_client.containers.run with the volumes and working_dir arguments, and compare os.listdir(os.getcwd()) with the container's ls output. Read the docker-py volume handling and Docker Engine mount behavior involved in this call. Done means the differing listings are explained and the issue is either corrected or narrowed to an environment-specific cause.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.