Running “apk add” command in a docker container with arguments [closed]

我怕爱的太早我们不能终老 提交于 2021-01-28 16:43:37

问题


I am trying to run

$ apk add pkg

in an alpine linux based container that isn't starting up.

Can anyone tell what is wrong with the following commands.

$ docker run  --rm  --entrypoint myimage:mytag 'apk add wget curl vim lynx'
docker: invalid reference format.
See 'docker run --help'.

$ docker run  --rm myimage:mytag --entrypoint 'apk add wget curl vim lynx'
container_linux.go:262: starting container process caused "exec: \"--entrypoint\": executable file not found in $PATH"
docker: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "exec: \"--entrypoint\": executable file not found in $PATH".

$  docker run  --rm myimage:mytag --entrypoint '/sbin/apk add wget curl vim lynx'
container_linux.go:262: starting container process caused "exec: \"--entrypoint\": executable file not found in $PATH"
docker: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "exec: \"--entrypoint\": executable file not found in $PATH".

$  docker run  --rm  --entrypoint "apk" myimage:mytag 'add wget curl vim lynx'
apk-tools 2.7.5, compiled for x86_64.

usage: apk COMMAND [-h|--help] [-p|--root DIR]
           [-X|--repository REPO] [-q|--quiet]

回答1:


Your last attempt was almost correct syntax. You just need to remove the quotes around the arguments.

docker run  --rm  --entrypoint apk myimage:mytag add wget curl vim lynx
ash-3.2$ docker run --rm --entrypoint apk alpine add wget curl vim lynx
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
(1/12) Installing ca-certificates (20191127-r2)
(2/12) Installing nghttp2-libs (1.40.0-r1)
(3/12) Installing libcurl (7.67.0-r0)
(4/12) Installing curl (7.67.0-r0)
(5/12) Installing gzip (1.10-r0)
(6/12) Installing ncurses-terminfo-base (6.1_p20200118-r4)
(7/12) Installing ncurses-libs (6.1_p2020


来源:https://stackoverflow.com/questions/62471471/running-apk-add-command-in-a-docker-container-with-arguments

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!