Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build docker image using docker py client #322

Merged
merged 1 commit into from
May 6, 2019
Merged

Conversation

yuyicg
Copy link
Contributor

@yuyicg yuyicg commented May 5, 2019

fix #317

@@ -31,7 +33,9 @@ def _build_docker_image(m_path, m_file, m_file_in_docker, timestamp):

with open(new_dfile, 'a') as df:
df.write("COPY " + m_file + " " + m_file_in_docker)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid creating temp file, and manual path join if possible:

docker_file = open(os.path.join(d_path,  "..", "Dockerfile.dev")).read() + "\nCOPY {m_file} {m_file_in_docker}\n".format(**locals())

fileobj = BytesIO(docker_file.encode())
... client.build(fileobj=fileobj, rm=True, tag=...)...


 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that the param path which specifies the build context is ignored when the param fileobj is used, see docker/docker-py#2105, so we could not execute the cmd COPY . /elasticdl in dockerfile to copy elasticdl source code into container.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that the param path which specifies the build context is ignored when the param fileobj is used, see docker/docker-py#2105, so we could not execute the cmd COPY . /elasticdl in dockerfile to copy elasticdl source code into container.

That's good to know.

Copy link

@majkrzak majkrzak Nov 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a PR with the fix. It might be the best way to handle it, due to the that it will directly be forwarded to docker compose.
docker/docker-py#2456

@yuyicg yuyicg merged commit b2a4ea6 into develop May 6, 2019
@yuyicg yuyicg deleted the build_docker_img branch May 6, 2019 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build local docker image using docker python api
3 participants