当 运行 在 docker 容器中时找不到 curl 命令
curl command not found when running inside docker container
运行 docker Debian 中的容器 Raspberry Pi。我有以下代码:
pi@raspi:~ $ docker container run --rm -it debian
root@64711f73f7da:/# time curl http://google.com
bash: curl: command not found
然而,如果我 运行 在 docker 容器外卷曲,它 运行 没问题:
pi@raspi:~ $ curl -V
curl 7.64.0 (arm-unknown-linux-gnueabihf) libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3
Release-Date: 2019-02-06
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
我也尝试过从 which curl
指定要在 docker 容器内卷曲的路径,它在此处指定了它的位置:/usr/bin/curl
。结果与上面类似(bash: /usr/bin/curl: No such file or directory
)
如何将卷曲到 Docker 容器内的 运行?
在这里找到答案:
但要详细说明:即使 Raspberry Pi 上的 Debian OS 安装了 curl 并且我可以从终端访问它,Docker 容器中的 Debian 映像也需要卷曲。因此,在 Docker 容器中,需要安装 root@d120d03b37db:/# apt-get update
和 root@d120d03b37db:/# apt-get install curl
以便 Debian 映像引用 curl
运行 docker Debian 中的容器 Raspberry Pi。我有以下代码:
pi@raspi:~ $ docker container run --rm -it debian
root@64711f73f7da:/# time curl http://google.com
bash: curl: command not found
然而,如果我 运行 在 docker 容器外卷曲,它 运行 没问题:
pi@raspi:~ $ curl -V
curl 7.64.0 (arm-unknown-linux-gnueabihf) libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3
Release-Date: 2019-02-06
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
我也尝试过从 which curl
指定要在 docker 容器内卷曲的路径,它在此处指定了它的位置:/usr/bin/curl
。结果与上面类似(bash: /usr/bin/curl: No such file or directory
)
如何将卷曲到 Docker 容器内的 运行?
在这里找到答案:
但要详细说明:即使 Raspberry Pi 上的 Debian OS 安装了 curl 并且我可以从终端访问它,Docker 容器中的 Debian 映像也需要卷曲。因此,在 Docker 容器中,需要安装 root@d120d03b37db:/# apt-get update
和 root@d120d03b37db:/# apt-get install curl
以便 Debian 映像引用 curl