Reputation: 981
I am trying to install mono package onto a Docker container, but mono requires git , autoconf, libtool, automake, build-essential , mono-devel, gettext packages.
the problem I am having is that libtool requires libc-dev, and libc-dev requires gcc compiler.
The docker container does not have any compiler installed, but my local machine does.
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
so my question is , what is the easiest way to get a gcc compiler onto a Docker container? should I just create a volume of these compiler directories into my docker container?
The reason I think I may need it is because I am running a website, and the website executes a docker image directly.
Upvotes: 43
Views: 141072
Reputation: 678
You could also grab an official image that already has GCC and/or some/most of the tools you need already installed. The docker store has a lot of official images already setup: https://store.docker.com/search?page_size=99&q=&source=verified
I'm not sure if it's the right mono, but they have a mono image: https://store.docker.com/images/4234a761-444b-4dea-a6b3-31bda725c427?tab=description
And an official GCC image: https://store.docker.com/images/06ad851d-f666-47d3-9ef3-e90535c141ec?tab=description
There's also buildpack-deps if you're going to be building stuff yourself: https://store.docker.com/images/9e56c286-5b40-4838-89fe-fd513c9c3bd6
You can browse by category: https://store.docker.com/search?page_size=99&q=&source=verified
And also directly search docker hub for mono or whatever your needs are: https://hub.docker.com/search/?isAutomated=0&isOfficial=0&page=1&pullCount=0&q=mono&starCount=0
Upvotes: 8
Reputation: 5795
In your Dockerfile:
FROM ubuntu
# ...
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get -y install gcc mono-mcs && \
rm -rf /var/lib/apt/lists/*
Upvotes: 51
Reputation: 54859
As I understand it, the OP has confused the terminology, and probably meant to ask:
installing a GCC compiler onto a Docker image
My answer starts by addressing the title of the question (regarding containers), then moves on to the intent of the question (regarding images).
If you can run a BASH shell in the container, then you don't need to manipulate a Dockerfile.
Say, for example, you try the hint from the docker run hello-world
example:
docker run -it ubuntu bash
Then just run these from the shell in the container...
apt-get update
apt-get install gcc
A key point is that apt-get install
in a raw Docker container may not behave as expected if you don't first run apt-get update
. Expect to see...
Unable to locate package gcc
The error message when trying to install g++
without apt-get update
is even more confusing due to "regex" substitution.
See also: http://www.liquidweb.com/kb/how-to-list-and-attach-to-docker-containers
docker ps -a ## list all available containers
and
docker exec -ti [CONTAINER ID] bash
This live-manipulation approach can also be used to creates images as the OP probably intended. Use docker commit
to save your live container as a new image.
Upvotes: 27