在 Docker 容器上安装 GCC 编译器
installing a GCC compiler onto a Docker Container
我正在尝试将单声道包安装到 Docker 容器中,但单声道需要
git、autoconf、libtool、automake、build-essential、mono-devel、gettext 包。
我遇到的问题是 libtool 需要 libc-dev,而 libc-dev 需要 gcc 编译器。
docker 容器没有安装任何编译器,但我的本地机器有。
arcolombo@acolombo:~/Documents/bedgraph_dockerfile$ dpkg --list |grep compiler
ii g++ 4:4.8.2-1ubuntu6 amd64 GNU C++ compiler
ii g++-4.8 4.8.2-19ubuntu1 amd64 GNU C++ compiler
ii gcc 4:4.8.2-1ubuntu6 amd64 GNU C compiler
ii gcc-4.8 4.8.2-19ubuntu1 amd64 GNU C compiler
ii hardening-includes 2.5ubuntu2.1 all Makefile for enabling compiler flags for security hardening
ii libllvm3.5:amd64 1:3.5-4ubuntu2~trusty2 amd64 Modular compiler and toolchain technologies, runtime library
ii libmono-compilerservices-symbolwriter4.0-cil 3.2.8+dfsg-4ubuntu1.1 all Mono.CompilerServices.SymbolWriter library (for CLI 4.0)
ii libxkbcommon0:amd64 0.4.1-0ubuntu1 amd64 library interface to the XKB compiler - shared library
ii mono-mcs 3.2.8+dfsg-4ubuntu1.1 all Mono C# 2.0 / 3.0 / 4.0 / 5.0 compiler for CLI 2.0 / 4.0 / 4.5
所以我的问题是,将 gcc 编译器安装到 Docker 容器中的最简单方法是什么?我应该只在我的 docker 容器中创建这些编译器目录的卷吗?
我觉得我可能需要它的原因是因为我是运行一个网站,网站直接执行一个docker图像。
在您的 Dockerfile 中:
FROM ubuntu
# ...
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get -y install gcc mono-mcs && \
rm -rf /var/lib/apt/lists/*
据我了解,OP混淆了术语,可能是想问:
installing a GCC compiler onto a Docker image
我的回答首先解决问题的标题(关于 容器),然后转向问题的意图(关于 图像).
如果可以在容器中运行一个BASHshell,那么就不需要操作一个Docker文件了。
例如,您尝试 docker run hello-world
示例中的提示:
docker run -it ubuntu bash
然后 运行 这些来自 shell 的容器...
apt-get update
apt-get install gcc
一个关键点是,如果您不先 运行 apt-get update
,原始 Docker 容器中的 apt-get install
可能不会按预期运行。期待看到...
Unable to locate package gcc
在没有 apt-get update
的情况下尝试安装 g++
时的错误消息由于 "regex" substitution 而更加混乱。
另请参阅:http://www.liquidweb.com/kb/how-to-list-and-attach-to-docker-containers
docker ps -a ## list all available containers
和
docker exec -ti [CONTAINER ID] bash
这种 live-manipulation 方法也可用于创建 OP 可能预期的图像。使用 docker commit
将您的实时容器保存为新图像。
您还可以获取已安装 GCC and/or some/most 所需工具的官方映像。 docker 商店已经设置了很多官方图片:https://store.docker.com/search?page_size=99&q=&source=verified
我不确定它是否是正确的单声道,但他们有单声道图像:https://store.docker.com/images/4234a761-444b-4dea-a6b3-31bda725c427?tab=description
以及官方 GCC 映像:https://store.docker.com/images/06ad851d-f666-47d3-9ef3-e90535c141ec?tab=description
如果您要自己构建东西,还有 buildpack-deps:https://store.docker.com/images/9e56c286-5b40-4838-89fe-fd513c9c3bd6
您可以按类别浏览:https://store.docker.com/search?page_size=99&q=&source=verified
并且还可以直接在 docker 集线器中搜索单声道或您需要的任何内容:https://hub.docker.com/search/?isAutomated=0&isOfficial=0&page=1&pullCount=0&q=mono&starCount=0
我正在尝试将单声道包安装到 Docker 容器中,但单声道需要 git、autoconf、libtool、automake、build-essential、mono-devel、gettext 包。
我遇到的问题是 libtool 需要 libc-dev,而 libc-dev 需要 gcc 编译器。
docker 容器没有安装任何编译器,但我的本地机器有。
arcolombo@acolombo:~/Documents/bedgraph_dockerfile$ dpkg --list |grep compiler
ii g++ 4:4.8.2-1ubuntu6 amd64 GNU C++ compiler
ii g++-4.8 4.8.2-19ubuntu1 amd64 GNU C++ compiler
ii gcc 4:4.8.2-1ubuntu6 amd64 GNU C compiler
ii gcc-4.8 4.8.2-19ubuntu1 amd64 GNU C compiler
ii hardening-includes 2.5ubuntu2.1 all Makefile for enabling compiler flags for security hardening
ii libllvm3.5:amd64 1:3.5-4ubuntu2~trusty2 amd64 Modular compiler and toolchain technologies, runtime library
ii libmono-compilerservices-symbolwriter4.0-cil 3.2.8+dfsg-4ubuntu1.1 all Mono.CompilerServices.SymbolWriter library (for CLI 4.0)
ii libxkbcommon0:amd64 0.4.1-0ubuntu1 amd64 library interface to the XKB compiler - shared library
ii mono-mcs 3.2.8+dfsg-4ubuntu1.1 all Mono C# 2.0 / 3.0 / 4.0 / 5.0 compiler for CLI 2.0 / 4.0 / 4.5
所以我的问题是,将 gcc 编译器安装到 Docker 容器中的最简单方法是什么?我应该只在我的 docker 容器中创建这些编译器目录的卷吗?
我觉得我可能需要它的原因是因为我是运行一个网站,网站直接执行一个docker图像。
在您的 Dockerfile 中:
FROM ubuntu
# ...
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get -y install gcc mono-mcs && \
rm -rf /var/lib/apt/lists/*
据我了解,OP混淆了术语,可能是想问:
installing a GCC compiler onto a Docker image
我的回答首先解决问题的标题(关于 容器),然后转向问题的意图(关于 图像).
如果可以在容器中运行一个BASHshell,那么就不需要操作一个Docker文件了。
例如,您尝试 docker run hello-world
示例中的提示:
docker run -it ubuntu bash
然后 运行 这些来自 shell 的容器...
apt-get update
apt-get install gcc
一个关键点是,如果您不先 运行 apt-get update
,原始 Docker 容器中的 apt-get install
可能不会按预期运行。期待看到...
Unable to locate package gcc
在没有 apt-get update
的情况下尝试安装 g++
时的错误消息由于 "regex" substitution 而更加混乱。
另请参阅:http://www.liquidweb.com/kb/how-to-list-and-attach-to-docker-containers
docker ps -a ## list all available containers
和
docker exec -ti [CONTAINER ID] bash
这种 live-manipulation 方法也可用于创建 OP 可能预期的图像。使用 docker commit
将您的实时容器保存为新图像。
您还可以获取已安装 GCC and/or some/most 所需工具的官方映像。 docker 商店已经设置了很多官方图片:https://store.docker.com/search?page_size=99&q=&source=verified
我不确定它是否是正确的单声道,但他们有单声道图像:https://store.docker.com/images/4234a761-444b-4dea-a6b3-31bda725c427?tab=description
以及官方 GCC 映像:https://store.docker.com/images/06ad851d-f666-47d3-9ef3-e90535c141ec?tab=description
如果您要自己构建东西,还有 buildpack-deps:https://store.docker.com/images/9e56c286-5b40-4838-89fe-fd513c9c3bd6
您可以按类别浏览:https://store.docker.com/search?page_size=99&q=&source=verified
并且还可以直接在 docker 集线器中搜索单声道或您需要的任何内容:https://hub.docker.com/search/?isAutomated=0&isOfficial=0&page=1&pullCount=0&q=mono&starCount=0