docker / docker/cli

docker import doesn't support exec entrypoint easily for Windows PowerShell users

Open
#1,685 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/question platform/desktop
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Description
From PowerShell on Windows, I'm trying to use docker import to create a new image from a tarball, and I'm using its --change command line option to set the ENTRYPOINT of the newly created image. I would like the newly created image to use an exec ENTRYPOINT and I think that I'm specifying that, but when the image is created, it is for some reason using a shell ENTRYPOINT

The root cause is that PowerShell's rules for escaping command line characters on Windows are particularly complicated to understand, and it would be nice if an exec ENTRYPOINT could be specified with ' as well as the existing ". By allowing ' it would make it easier for Windows PowerShell users to craft command lines.

Steps to reproduce the issue:
Create a tarball, then import it. In these minimal repro steps the tarball isn't a valid image for a container that can start, but these steps are sufficient to demonstrate the issue, and the bug also happens for real images (feel free to use a different tarball if you have one to hand).

  1. echo Hello >world.txt
  2. tar -cf tarball.tar world.txt
  3. docker import --change "ENTRYPOINT [""cat"", ""world.txt""]" tarball.tar
  4. docker inspect the image that you just created (docker import outputs to stdout the sha256 hash that you need to use), for example on my machine it was docker inspect sha256:d07c694f5b035edd8c87df2a6c0087a4ca866f8b0958b1d6edcedeaae44bac4b (yours will be different because the modified date of the file will be different)

Describe the results you received:
docker inspect will output a lot of JSON and ENTRYPOINT is mentioned twice; ignore the mention in ContainerConfig because it isn't relevant for us, and instead look at the mention in Config which is:

            "Entrypoint": [
                "/bin/sh",
                "-c",
                "[cat, world.txt]"
            ],

Describe the results you expected:
The results that I received above demonstrate that, even though the command line switch specified an exec ENTRYPOINT, it has been incorrectly specified as a shell ENTRYPOINT in the image that was created.

Instead of the above, I expected the JSON to contain:

            "Entrypoint": [
                "cat",
                "world.txt"
            ],

If instead I replace step 3 above with docker import --change 'ENTRYPOINT [""""cat"""", """"world.txt""""]' tarball.tar then it works, but it's not easy to understand that I need to craft a command line like that, so it'd be good if Docker could provide more help either via documentation or allowing more flexibility to ENTRYPOINT.

Output of docker version:

Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:31 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info:

Containers: 159
 Running: 0
 Paused: 0
 Stopped: 159
Images: 486
Server Version: 18.09.2
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: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce
runc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec
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-00155d284706
ID: TWPV:IAQZ:O6KU:5QTX:JYG2:FYE7:CRKH:HOWY:TVX4:XJG2:LZOV:AXDT
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 22
 Goroutines: 46
 System Time: 2019-02-22T08:55:31.3298626Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

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

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 at the docker import handling for the --change option and its existing ENTRYPOINT parsing. Reproduce the issue with the PowerShell command examples, then inspect the resulting image configuration. Done means an ENTRYPOINT using the proposed single-quote form is stored as an exec entrypoint, while existing forms continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go, powershell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.