Using docker in Fedora for your development work
Last week I worked on DNF for the first time. In this post I am going to explain how I used Docker and a Fedora cloud instance for the same.
I was using a CentOS vm as my primary work system for last two weeks and I had access to a cloud. I created a Fedora 20 instance there.
The first step was to install docker in it and update the system, I also had to upgrade the selinux-policy package and reboot the instance.
# yum upgrade selinux-policy -y; yum update -y
# reboot
# yum install docker-io
# systemctl start docker
# systemctl enable docker
Then pull in the Fedora 21 Docker image.
# docker pull fedora:21
The above command will take time as it will download the image. After this we will start a Fedora 21 container.
# docker run -t -i fedora:21 /bin/bash
We will install all the required dependencies in the image, use yum as you do normally and then get out by pressing Crrl+d.
[root@3e5de622ac00 /]# yum install dnf python-nose python-mock cmake -y
Now we can commit this as a new image so that we can reuse it in the future. We do this by docker commit
command.
# docker commit -m "with dnf" -a "Kushal Das" 3e5de622ac00 kushaldas/dnfimage
After this the only thing left to start a container with this newly created image and mounted directory from host machine.
# docker run -t -i -v /opt/dnf:/opt/dnf kushaldas/dnfimage /bin/bash
This command assumes the code is already in the /opt/dnf
of the host system. Even if I managed to do something bad in that
container, my actual host is safe. I just have to get out of the container and start a new one.