From Fedora Project Wiki

mNo edit summary
(Fixed some Grammer and formatting mistakes)
 
Line 4: Line 4:


* First, Install Docker: sudo dnf install docker docker-io There is great instructions on installing docker on fedora here: [[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
* 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
* I then had to set selinux to permissive, sudo '''vim /etc/selinux/config''' and change the line of SELINUX= to SELINUX=permissive
* reboot
* reboot
Line 12: Line 12:


== Pull Down a Fedora Image ==  
== Pull Down a Fedora Image ==  
* Pull down the Fedora21 image: docker pull fedora:21
* Pull down the Fedora21 image: ''<code>docker pull fedora:21</code>''


== Run the Docker image, or Spawn a container that you will update ==
== Run the Docker image, or Spawn a container that you will update ==
* Spawn the docker:<code> docker run -t -i fedora:21 /bin/bash </code>
* Spawn the docker:<code> docker run -t -i fedora:21 /bin/bash </code>
* Now in the docker shell, '''run yum update''', and then '''yum install publican-fedora'''
* Now in the docker shell, '''run yum update''', and then '''yum install publican-fedora'''
* '''in another shell on your host machine''', run the command <code>docker ps</code>, '''take note of the Container ID''':
* '''in another shell on your host machine''', run the command: <code>docker ps</code>, '''take note of the Container ID''':
<pre>
<pre>
CONTAINER ID        IMAGE                    COMMAND            CREATED            STATUS              PORTS              NAMES
CONTAINER ID        IMAGE                    COMMAND            CREATED            STATUS              PORTS              NAMES
a5021f01b7ff        fedora:21  "/bin/bash"        16 seconds ago      Up 15 seconds                          gloomy_wright </pre>
a5021f01b7ff        fedora:21  "/bin/bash"        16 seconds ago      Up 15 seconds                          gloomy_wright </pre>
== Commit your changes into a new Docker Image ==       
== Commit your changes into a new Docker Image ==       
9. Commit your changes to make a new docker image: <code>docker commit a5021f01b7ff fedora-publican </code> # In this example, I named my new image fedora-publican
* Commit your changes to make a new docker image: ''<code>docker commit a5021f01b7ff fedora-publican </code>'' # In this example, I named my new image fedora-publican
10. Now you should have a couple of Fedora Docker images, verify this with <code>docker images</code>:
* Now you should have a couple of Fedora Docker images, verify this with the command: ''<code>docker images</code>'':
<pre>
<pre>
REPOSITORY          TAG                IMAGE ID            CREATED            VIRTUAL SIZE
REPOSITORY          TAG                IMAGE ID            CREATED            VIRTUAL SIZE
Line 30: Line 30:
</pre>
</pre>
== Spawn a container that can mount your local file system ==  
== Spawn a container that can mount your local file system ==  
Now, you need to make your docker be able to mount your local disk from within the docker shell. To do this is similar to NFS, you need to do:<pre> docker run -v <localfilesystempath>:<pathwithinthedocker> -ti <docker image> /bin/bash </pre>
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:<pre> docker run -v <localfilesystempath>:<pathwithinthedocker> -ti <docker image> /bin/bash </pre>


For example my Docker command is:  
For example my Docker command is:  
Line 37: Line 37:


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.  
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 ==  
== helpful items that can be added in .bashrc ==  
I then take it a little further and make an alias in my .bashrc:<pre>
I then take it a little further and make an alias in my .bashrc:<pre>
Line 50: Line 51:
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:
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:
<pre>alias cleandock='docker rm $(docker ps -aq)'</pre>
<pre>alias cleandock='docker rm $(docker ps -aq)'</pre>
The command: <code>docker rm $(docker ps -aq)</code> 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)
The command: ''<code>docker rm $(docker ps -aq)</code>'' 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)

Latest revision as of 01:00, 9 July 2015

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
docker.io/fedora    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)