Skip to content

Instantly share code, notes, and snippets.

@alext234 alext234/Dockerfile
Last active Nov 10, 2019

Embed
What would you like to do?
A simple ubuntu container with gcc and cmake
FROM ubuntu:xenial
MAINTAINER alex
# update and install dependencies
RUN apt-get update \
&& apt-get install -y \
software-properties-common \
wget \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt-get update \
&& apt-get install -y \
make \
git \
curl \
vim \
vim-gnome \
&& apt-get install -y cmake=3.5.1-1ubuntu3 \
&& apt-get install -y \
gcc-4.9 g++-4.9 gcc-4.9-base \
gcc-4.8 g++-4.8 gcc-4.8-base \
gcc-4.7 g++-4.7 gcc-4.7-base \
gcc-4.6 g++-4.6 gcc-4.6-base \
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 100
@alext234

This comment has been minimized.

Copy link
Owner Author

alext234 commented Nov 25, 2016

ubuntu version: 16.04 (xenial)

@alext234

This comment has been minimized.

Copy link
Owner Author

alext234 commented Nov 25, 2016

added vim-gnome (gvim)

@alext234

This comment has been minimized.

Copy link
Owner Author

alext234 commented Nov 25, 2016

In order to run gvim from the container,

  1. Give docker the rights to access X-server
xhost +local:docker
  1. Run a terminal in container
sudo docker run  -it  --rm -e DISPLAY         -v /tmp/.X11-unix:/tmp/.X11-unix  my-docker-gcc
  1. Run gvim from the terminal
gvim
@alext234

This comment has been minimized.

Copy link
Owner Author

alext234 commented Nov 28, 2016

an example of how to build (with Makefile generated from cmake) inside the container
(from /home/u/LibPcap directory)

sudo docker run --rm -v "$PWD":/home/u/NetCapStatistics -w /home/u/NetCapStatistics/build alext234/my-docker-gcc cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release ..
sudo docker run --rm -v "$PWD":/home/u/NetCapStatistics -w /home/u/NetCapStatistics/build alext234/my-docker-gcc make


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.