Skip to content

Instantly share code, notes, and snippets.

@lmiphay
Created April 29, 2015 15:52
Show Gist options
  • Save lmiphay/53b006b5f05e0c6b62db to your computer and use it in GitHub Desktop.
Save lmiphay/53b006b5f05e0c6b62db to your computer and use it in GitHub Desktop.
gentoo Dockerfile - openrc version
wget http://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64/stage3-amd64-20150423.tar.bz2
bzcat stage3-amd64-20150423.tar.bz2 | docker import - 'gentoo:latest'
FROM gentoo:latest
MAINTAINER Paul Healy <ph>
EXPOSE 22
RUN echo "root:supersecret" | chpasswd
RUN mkdir /usr/portage
RUN rc-config add sshd
ENTRYPOINT ["/sbin/init"]
docker run -p 2222:22 -v /usr/portage:/usr/portage gentoo:latest
@lmiphay
Copy link
Author

lmiphay commented Feb 8, 2018

import/create base image

wget http://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64/stage3-amd64-20180206T214502Z.tar.xz
xzcat stage3-amd64-20180206T214502Z.tar.xz | docker import - 'gentoo:20180206'

Dockerfile

FROM gentoo:20180206
MAINTAINER Paul Healy
EXPOSE 22
RUN echo "root:supersecret" | chpasswd
RUN mkdir -p /lib64/rc/init.d /lib64/rc/cache /usr/portage \
&& rc-config add sshd \
&& sed -i -e 's/#rc_sys=""/rc_sys="docker"/' etc/rc.conf \
&& sed -i -e 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' etc/ssh/sshd_config
ENTRYPOINT ["/sbin/init"]

create runnable image (Dockerfile in this directory)

docker build -t gentoo:latest .

create/run container

docker run -p 2222:22 -v /usr/portage:/usr/portage gentoo:latest

attach to running container

docker ps
docker exec -i -t CONATINER /bin/bash
docker attach CONTAINER

cleanup

docker stop -t 1 CONTAINER
docker rmi -f gentoo:latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment