From Fedora Project Wiki

Revision as of 01:00, 9 July 2015 by Grundblom (talk | contribs) (Fixed some Grammer and formatting mistakes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Here is my guide on how I used Docker to run Fedora21 so I can build with Publican, the guide is far from perfect and I will be editing it and making it better. Hopefully it will provide some help to others who had issues with Publican on Fedora22

Install Docker

  • First, Install Docker: sudo dnf install docker docker-io There is great instructions on installing docker on fedora here: docker
  • Then start, and enable docker: sudo systemctl start docker, sudo systemctl enable docker
  • I then had to set selinux to permissive, sudo vim /etc/selinux/config and change the line of SELINUX= to SELINUX=permissive
  • reboot
  • Modify your local user account so you do not have to use sudo all the time to run docker:
usermod -a -G docker USERNAME
systemctl restart docker

Pull Down a Fedora Image

  • Pull down the Fedora21 image: docker pull fedora:21

Run the Docker image, or Spawn a container that you will update

  • Spawn the docker: docker run -t -i fedora:21 /bin/bash
  • Now in the docker shell, run yum update, and then yum install publican-fedora
  • in another shell on your host machine, run the command: docker ps, take note of the Container ID:
CONTAINER ID        IMAGE                    COMMAND             CREATED             STATUS              PORTS               NAMES
a5021f01b7ff        fedora:21   "/bin/bash"         16 seconds ago      Up 15 seconds                           gloomy_wright 

Commit your changes into a new Docker Image

  • Commit your changes to make a new docker image: docker commit a5021f01b7ff fedora-publican # In this example, I named my new image fedora-publican
  • Now you should have a couple of Fedora Docker images, verify this with the command: docker images:
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
fedora-publican     latest              6acd72a1a9cb        2 weeks ago         865.3 MB    latest              ded7cd95e059        5 weeks ago         186.5 MB

Spawn a container that can mount your local file system

Now we need to make the container able to mount your local disk from within the docker shell. To do this is similar to NFS, To do this run a command in the following template:

 docker run -v <localfilesystempath>:<pathwithinthedocker> -ti <docker image> /bin/bash 

For example my Docker command is:

docker run -v /home/glen/Documents/fedora:/srv/fedora -ti fedora-publican /bin/bash

This drops me into a shell in the docker, so I can go to /srv/fedora and then go to whatever guide I need to and use publican to build the guide. I purposely mount the root of my fedora guides this way. If you mount too specific of a path, you wont be able to traverse it within your container.

I leave my docker at a bash shell open so I can make changes and test the build over and over, I am sure there is a better way to do this, but so far this works for me.

helpful items that can be added in .bashrc

I then take it a little further and make an alias in my .bashrc:

alias publicandocker='docker run -v /home/glen/Documents/fedora:/srv/fedora -ti fedora-publican /bin/bash'

Only run the container for the application you need

Note: Since the Fedora docker was not built by myself, or someone I know / trust , I resist the urge to do Git pushes, or log into anything via SSH. I do those tasks outside of the docker shell on my local host, and use the docker container to only run the publican – build process.

Use the Tool

Now with a working Fedora21 container with publican-fedora you should be able to build your guides successfully

Container cleanup

So, after a while, your going to have some spent and used containers. I like to clean up my containers by making an alias in my .bashrc:

alias cleandock='docker rm $(docker ps -aq)'

The command: docker rm $(docker ps -aq) will make docker clean up completed containers, however this command will not purge running containers. To do that you need to add the flag -rf. (This takes a while, on a Intel Core i7 with a intel 520 series SSD, it takes minutes to purge tens of containers)