installing a GCC compiler onto a Docker Container

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


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.


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/*

Tags:

Docker

Gcc