Pulling Fedora Container#
$ docker pull fedora:29
See also:
Running Fedora Container#
To run Fedora container:
$ docker run \
--name fedora \
--hostname=server.example.com \
--privileged \
--tmpfs /tmp \
--tmpfs /run \
--volume /sys/fs/cgroup:/sys/fs/cgroup:ro \
--detach \
-ti \
fedora:29 "/usr/sbin/init"
To access the container:
$ docker exec -ti fedora /bin/bash
Creating Fedora Container#
Create the following Dockerfile:
FROM fedora:29
MAINTAINER http://fedoraproject.org/wiki/Cloud
ENV container docker
RUN dnf -y update && dnf clean all
RUN dnf -y install systemd && dnf clean all && \
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup", "/tmp", "/run" ]
CMD ["/usr/sbin/init"]
To build the image:
$ docker build -t fedora .
To run the container:
$ docker run --name fedora --detach -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro fedora /usr/sbin/init