Definite's Extractor

My findings on Life, Linux, Open Source, and so on.

Chewable Fedora Atomic

Fedora Atomic is an operating system targets to containers. However, the documentation, for me, is very hard to read. In this document, I will share my adventure with Fedora Atomic, starting with post installation.

I have installed Fedora Atomic, now what?

Let’s say you want to install the tree and docker-compose for better understanding the directory structure of your new host; you also need to ping a host every hour; and of course, you want your shiny new docker application to be deploy to this machine.

Package Install with rpm-ostree

Atomic Host has neither yum nor dnf, it has rpm-ostree. It is not just the name change, it changes the behavior.
For example, for typical Fedora, tree can be run immediately after install the package tree, but with Atomic, after run:

sudo rpm-ostree -y install tree docker-compose

you have to reboot to use them, as rpm-ostree just install them “off-line”.

Note that I have also installed docker-compose. For some reason, docker-compose is not installed by default in Atomic Host. I expected I will encounter many projects that use docker-compose.

Schedule Command with systemd.timer

Another gotcha is crontab cannot be installed. Fortunately, you can use systemd.timer instead.

For pinging a host for every 1 hours, you need two files:

  • /etc/systemd/system/example.service
    # oneshot as ping -c 4 will exit automatically
    # Actual command to run
    ExecStart=/sbin/ping -c 4
    # Run in multi-user mode when enabled
  • /etc/systemd/system/example.timer
    # Run 15 minutes after boot
    # Every hour after last activated
    # Run in multi-user mode when enabled

Enable the service and timer, then start the service:

sudo systemctl enable example.service
sudo systemctl enable example.timer
sudo systemctl start example.service

“Atomize” your Dockerfile

You CAN use it as typical docker, no problem. But do you really want to ask your users and yourself to type all the commands in the lengthy installation instructions?

Atomic smooth the experience by integrating the installation instructions in Dockerfile. I have a living example, Dockerfile of zanata-sinopia-docker-file, a dockerize npm repository server.

Look the line LABEL INSTALL=, basically it achieves two goals:

  1. Copy the required files from the container to host’s /tmp : this is done with docker privileged mode.
  2. Rest of the installation instructions on host: Especially with the tasks that required root of the host.

You can write the similar for your uninstall instructions (LABEL UNINSTALL) and run instructions (LABEL RUN).

After you done with development:

  1. At your development box, docker push your images.
  2. At the Atomic Host, to install the image, run:
    atomic install [repo]/[image]
  3. At the Atomic Host, to run the container:
    atomic run [repo]/[image]

That is it.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: