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

strange issue when building image with build-arg on windows via Makefile #38466

Closed
Liu233w opened this issue Dec 31, 2018 · 1 comment
Closed

Comments

@Liu233w
Copy link

Liu233w commented Dec 31, 2018

Description

Use the file below to reproduce it:

Makefile:

build:
	docker build . -f testArgPath.Dockerfile -t test-image --build-arg path=/var/testPath
run:
	docker run --rm test-image pwd
clean:
	docker image rm test-image

testArgPath.Dockerfile:

FROM alpine
ARG path
WORKDIR ${path}

running on windows via command prompt

Steps to reproduce the issue:

  1. make build run clean

Describe the results you received:

d:\Sources\docker>make build run clean
docker build . -f testArgPath.Dockerfile -t test-image --build-arg path=/var/testPath
Sending build context to Docker daemon  4.096kB
Step 1/3 : FROM alpine
 ---> 3f53bb00af94
Step 2/3 : ARG path
 ---> Running in 1d0cea8985b2
Removing intermediate container 1d0cea8985b2
 ---> 05049de90a53
Step 3/3 : WORKDIR ${path}
 ---> Running in a778a99b6571
Removing intermediate container a778a99b6571
 ---> 264f464ff6fc
Successfully built 264f464ff6fc
Successfully tagged test-image:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
docker run --rm test-image pwd
/D:/Software/msys2/var/testPath          <================== see this line =========
docker image rm test-image
Untagged: test-image:latest
Deleted: sha256:264f464ff6fc249e949fbfe5a7e5efd4c39481f8f9bcc9c58cfe8d25d83d7d85
Deleted: sha256:6442f5ad8e93b2e06f86c8e9acab852acfc5ea06255917e319be8aa0c9777f3d
Deleted: sha256:05049de90a53fd0bedbd61aff0431e92e260e8b02dbddf0db0c383c2217bd1f5

Describe the results you expected:

The output of pwd should be /var/testPath

Additional information you deem important (e.g. issue happens only occasionally):

I installed msys2 on windows to use make, by simply running pacman -S make and adding the bin path (d:\Software\msys2\usr\bin\ on my computer) of msys2 to the path environment variable.

Output of docker version:

docker on windows

docker version:

Docker version 18.09.0, build 4d60db4

docker desktop version:

Version 2.0.0.0-win81 (29211)
Channel: stable
Build: 4271b9e

Output of docker info:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 12
Server Version: 18.09.0
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d35fc13
ID: H4F2:SVUL:BGTY:7PPJ:XJHS:3NJE:ZC3C:CSUD:4YFP:R3Z2:DMJO:BTEZ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 22
 Goroutines: 47
 System Time: 2018-12-31T17:26:27.8167808Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Registry Mirrors:
 https://registry.docker-cn.com/
 http://8cc5e21c.m.daocloud.io/
Live Restore Enabled: false
Product License: Community Engine

Additional environment details (AWS, VirtualBox, physical, etc.):

@Liu233w
Copy link
Author

Liu233w commented Jan 3, 2019

I finally figured it out. Msys2 will correct the path automatically and change /var/testPath to /D:/Software/msys2/var/testPath in shell parameters. To fix that, just set environment variable MSYS2_ARG_CONV_EXCL="*" or add a line to the beginning of makefile like this:

export MSYS2_ARG_CONV_EXCL = *

build:
	echo $$MSYS2_ARG_CONV_EXCL
	docker build . -f testArgPath.Dockerfile -t test-image --build-arg path=/var/testPath
run:
	docker run --rm test-image pwd
clean:
	docker image rm test-image

the link that describe the feature: msys2/MSYS2-packages#84

@Liu233w Liu233w closed this as completed Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants