Fedora Developer Portal – how to contribute

The great thing about working at Red Hat is being part of the Fedora community and as a part of this group of enthusiastic people you get close to cool, interesting, awesome, innovative, important... projects. And you get close to them while they are at the beginning and you can influence where they go.

One of those projects is Fedora Developer Portal which will help developers to start their projects on Fedora. It will help you figure out what languages, frameworks, or databases are available in our distribution. How to use Docker, Vagrant or Copr build system to package, distribute and deploy your projects. There is already content ready for you to help you with setting things up for Arduino. Much of other content is in preparations and even more is waiting for you to come and join the project!

My contribution to the project so far has been making it easy for you to contribute. I helped guys with contribution guidelines and I created a Docker image which will let you run the website locally so that you can review your contributions.

This is what you can also find in a README.md for the website project:

$ sudo docker run -it --rm developerportal/devel
[sudo] password for vpavlin: 
Previous HEAD position was 702f2a3... move logo to static directory
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
Already up-to-date.
Configuration file: /opt/developerportal/website/_config.yml
/home/dp/.gem/ruby/gems/jekyll-lunr-js-search-0.3.0/lib/jekyll_lunr_js_search/version.rb:3: warning: already initialized constant Jekyll::LunrJsSearch::VERSION
/opt/developerportal/website/_plugins/jekyll_lunr_js_search.rb:245: warning: previous definition of VERSION was here
 Source: /opt/developerportal/website
 Destination: /opt/developerportal/website/_site
 Generating... 
 Lunr: Creating search index...
 Build Warning: Layout 'page' requested in content/fedora_features/Fedora23_Self_contained_Changes.md does not exist.
 Build Warning: Layout 'page' requested in content/fedora_features/Fedora23_System_Wide_Changes.md does not exist.
...
 Lunr: Index ready (lunr.js v0.4.5)
 done.
 Auto-regeneration: enabled for '/opt/developerportal/website'
Configuration file: /opt/developerportal/website/_config.yml
 Server address: http://172.17.0.5:8080/
 Server running... press ctrl-c to stop.

You can see a server address - that's what you need to copy to your browser to view the page.

Screenshot from 2015-09-02 09-39-51

Now you have the local dev instance running. What if you want to display your changes? First, you clone the content repository.

$ git clone https://github.com/developer-portal/content

Then you will have to modify the run command a bit - specifically, add a volume mount (replace $PWD/content with the path to the cloned content repository):

$ sudo docker run -it --rm -v $PWD/content:/opt/developerportal/website/content developerportal/devel

Ok, now what if you don't want to contribute to content of the portal but rather to help guys making the website awesome? The approach is the same as above. First, you clone the website repository.

$ git clone https://github.com/developer-portal/website

Then you run the container just with the mount for website instead of content.

$ sudo docker run -it --rm -v $PWD/website:/opt/developerportal/website developerportal/devel

Jekyll is used to render the website and it's content and it's set up in the way that whenever you edit any file the website re-renders itself and you can simply refresh the browser when it's finished.

The rest is easy - you change whatever you want, push to your fork on Github, submit a pull request. Once it's reviewed, your changes will appear on the web. Yay!

Ok, my job is done here. Now it's your turn to contribute and promote it further!:)

How to (be a) man on Atomic Host

One major thing missing on the Atomic Host are manual pages. Not a terrible thing - you can always google for them, right? But what if you cannot? Then there is the Fedora Tools Docker image. Try this:

-bash-4.3$ alias man="sudo atomic run vpavlin/fedora-tools man"
-bash-4.3$ man systemd

You should see a manual page for systemd. Thinking about it, that's it. Nothing more you need to now about it. Simple:)

 

Running git on Atomic Host with Fedora Tools image

I added the Fedora Tools image to Fedora-Dockerfiles repository, as you might know from my earlier post. I'd like to introduce you to one use case for this image - git.

When I started to work more on Docker images, I started using Atomic Host(s) for testing as they boot faster and are easier to set up than classic installations. Problem was to get data in those VMs running Atomic Host as git was not present. That's where I first really appreciated the tools image.

bash-4.3# yum
bash: yum: command not found
bash-4.3# git
bash: git: command not found
bash-4.3# atomic run fedora/tools
[root@localhost /]# cd /host/home/vagrant/
[root@localhost vagrant]# git clone https://github.com/fedora-cloud/Fedora-Dockerfiles
Cloning into 'Fedora-Dockerfiles'...
remote: Counting objects: 2189, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 2189 (delta 3), reused 0 (delta 0), pack-reused 2180
Receiving objects: 100% (2189/2189), 915.13 KiB | 901.00 KiB/s, done.
Resolving deltas: 100% (1014/1014), done.
Checking connectivity... done.
[root@localhost vagrant]# exit
bash-4.3# ls
Fedora-Dockerfiles sync

It's simple, right? You can see there is neither yum/dnf, nor git on the host, but still, I was able to clone the repository from Github very easily. The important thing to notice is the path I cd'ed to: /host/home/vagrant. You can see /host prefix there. That's where the host's filesystem is mounted and where I can access it and modify it.

You can review the docker run command for the tools image f.e. with this command:

bash-4.3# docker inspect --format='{{.Config.Labels.RUN}}' vpavlin/fedora-tools
docker run -it --name NAME --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=NAME -e IMAGE=IMAGE -v /run:/run -v /var/log:/var/log -v /etc/localtime:/etc/localtime -v /:/host IMAGE

Obviously, you can do more, not just clone the repo - you can run commit, push, checkout or anything else the same way.

Fedora Tools Docker image

I got this request from my colleagues if there is something like Red Hat Atomic Enterprise Tools container image available for Fedora or CentOS. The answers was no, there isn't, thus I started to work on it. I'd like to tell you what it is and why do I invest my time into it.

First of all, Fedora Tools image is meant to be used mostly on Atomic Host as there is no way to install missing tools with yum or dnf. We could create tons of small images each containing a single tool. But that would a) make it hard for users to find all the tools, b) consume more space then a single image if you decide to use many (all...) of them, c) be hard to maintain.

These 3 reasons lead us to create a single image containing big number of tools important to sysadmins, performance analysts, or just users that need man pages on Atomic Host. This image is pretty big (more than 1 GB), but can be pretty useful.

Current version of the Dockerfile can be found in Fedora-Dockerfiles repository. You can find the list of additional packages (to what's already in a base image) starting on line 13.

The basic information on how to use the Fedora Tools Docker image can be found in README file and I hope to provide more how-to's here soon:).

I've set up an automated build as vpavlin/fedora-tools under my namespace on Docker Hub. To try the image, you can do:

atomic run vpavlin/fedora-tools

Enjoy;-)

Taskwarrior in a Docker container

So I heard about great tool - Taskwarrior. Cool, let's try it. Well, sure, but why should I install another bunch of RPMs to my laptop? Not that it matters a lot, but I hate to have my system bloated with unused packages which are installed as dependencies, but stay there when I remove the "root" package. Let's go crazy and create a simple Taskwarrior container.

I started with plain Dockerfile.

FROM fedora
MAINTAINER Vaclav Pavlin <vpavlin@redhat.com>
RUN dnf -y install task
VOLUME /task_data
ENTRYPOINT ["task"]

 

That was not ideal because the final container missed very important settings - data location. So I added 2 lines which initialized ~/.taskrc and changed the data location to a well known path. I also added man command to the mix so that I can display manual pages for Taskwarrior. Final Dockerfile follows

FROM fedora
MAINTAINER Vaclav Pavlin <vpavlin@redhat.com>
RUN dnf -y install task man
VOLUME /task_data
RUN yes | task || true
RUN sed -i 's#\(data.location=\).*#\1/task_data#' ~/.taskrc
ENTRYPOINT ["task"]

Still pretty simple, isn't it? Now, how to run this image? Just call the following command, there is an image ready for you on Docker Hub:

docker run -it --rm -v $HOME/.task:/task_data vpavlin/task

The command above will start a container which will initialize few files in $HOME/.task directory and print output like this:

[task next]
No matches.

You can try some fancy stuff with Taskwarrior itself now:

Screenshot from 2015-08-18 16-40-32Well, it works. But also is pretty ugly. Let's make the user experience nicer and smoother. You can simply create an alias for docker run command. For example like this one:

$ alias task="docker run -it --rm -v $HOME/.task:/task_data vpavlin/task"
$ task
[task next]

ID Age Project Tag Description Urg 
 1 6s vpavlin.eu blog today This is a test taks for my blog post 1.9

1 task

Then, when you call task, you will get the same output as if Taskwarrior was installed on you machine. Also your data will be stored locally so you don't have to be afraid of losing them when you remove container/image.

I also wrote a simple task function which you can paste in your ~/.bash_aliases file which lets you either use Taskwarrior as with the alias above, or you can do

task CMD man task

Note CMD in the command - that will let the bash function know to run different command than the one specified in Dockerfile - f.e. view the man pages.

I also strongly suggest to set the data location (i.e. the volume mount, or $data_dir variable in the function) to a backed up folder. I, for example, use Dropbox, so that I can access and modify my tasks from any machine (basically just by pulling and running the Docker image).

Links:

 

Stuhleck se City Ski, aneb moje první setkání s Alpami

Na snowboardu jsem se naučil už pěkných pár let zpátky, ale nikdy jsem tomu ježdění moc nedal. Ani jsem na horách nestrávil moc času. Moje zážitky ze sjezdovky se v zásadě omezovaly na sbírání sebe sama ze země, vytřepávání sněhu z bundy a protahování pokroucených a potlučených končetin a tak podobně:).

Letos se to ale nějak zlomilo - vyrazili jsme s Marťou na pár dní do Vrbna pod Pradědem a vážně jsem si to užil. V podstatě bez zranění, beze strachu při pohledu dolů ze sjezdovky a dokonce jsem si na tom prkýnku nepřipadal ani jako úplná lama. Nebýt všudypřítomné mlhy, bylo to skoro perfektní. Protože to bylo tak super, rozhodli jsme se vyrazit na hory ještě jednou. Já v Alpách nikdy nebyl a moc jsem chtěl zjistit, jestli to stojí za to. Narazili jsme u piva na CitySki.cz a jejich jednodenní lyžovačky pro měšťáky a zaujal nás Stuhleck.

Za 1 500 Kč cesta a skipas, ráno tam, večer zpátky, no nekupte to! Takže se Tomáš zaúkoloval, že bude hlídat termíny a když to přišlo, poslali jsme rezervaci, přečetli si vtipný potvrzovací mail a nemohli se dočkat. Systém je to jednoduchý - předem se nic neplatí, všechno až před nástupem do autobusu - 1 500 Kč + 2 € záloha na skipas, který jsme dostali hned při nástupu, takže žádné zbytečné zdržování po příjezdu.

Fascinující na cestě tam bylo, že s tím, jak jsme stoupali, vůbec nepřibývalo sněhu;). Pak jsme projeli tunelem a...pořád nic. Jenže potom jsme koukli vlevo a on tam kopec, zasněžený, vysoký, s lanovkou..aháá. Tak tohle jsou ty Alpy. Takže nasedneme na čtyřsedačkovou lanovku, jedeme do kopce, a pak z kopce, a pak hodně do kopce, vystoupíme, sjedeme pár metrů a jedeme zase do kopce. Nahoře zjistíme, že jsme sice na hoře, ale ne ještě úplně nahoře. Takže dolů, držet se vlevo a hurá na vrchol.

Jezdilo se parádně. Bylo znát, že dole je cca +10 °C, takže sníh na spodní části sjezdovky stál docela za prd, ale nahoře to byla nádhera. Bylo jasno a mně se taky docela vyjasnilo - promiň Vrbno, bylo v tobě pěkně, ale příští rok chci do Alp.

A co ještě říct k samotnému City Ski? Organizace bezproblémová, autobus bez připomínek, řidiči velmi zvláštní s neustálými pokusy o vtipy, což vedlo pouze k našim pochybovačným pohledům ohledně jejich duševního zdraví (nic ve zlém, díky, že jste nás někde nevyklopili, nebo tak). Na zpáteční cestě nám pustili film, ale vzhledem k umístění 2 obrazovek a tomu, že jsme seděli až vzadu "na pětce", jsem nic neviděl - slyšel jsem na druhou stranu moc dobře, což mělo za následek, že jsem se ani cestou nemohl prospat, škoda:).

Každopádně si myslím, že to nebyl náš poslední výlet se City Ski a pravděpodobně jsme se ani naposledy neviděli se Stuhleckem. Ale teď už sbohem zimo a díky za všechny ryby...eh, sjezdy.

Jak jsem skoro zazdil InstallFest 2015

To máte tak, spousta práce, trocha nepozornosti a pozvánka na víc akcí (skoro) najednou. Tenhle koktejl okolností způsobil, že jsem byl poměrně dlouhou dobu přesvědčen, že InstallFest 2015 se koná přístí víkend (tedy 14. a 15. března). To si tak ve čtvrtek večer projíždíte Twitter a najednou zmínka o tom, že placky už jsou připraveny na sobotu. Sobotu? Jako tuhle sobotu? Hmm..

Snímek z 2015-03-07 17:58:04

A fakt že jo! No co, jdete spát a říkáte si: "Slajdy udělám zítra v práci, to bude hned." Jenže v práci furt někdo otravuje, něco chce, takže uděláte prd. Tak prý doma, večer. Jenže to se vypravíte na jídlo a pivo. Teda hned po tom si aspoň ráno koupíte jízdenku;). Tak fajn, slajdy se spáchají ráno před odjezdem. Ráno se vyštracháte z postele, koukáte na prázdnou prezentaci a říkáte si: "Co jsem to těm lidem vlastně chtěl říct, když jsem tu prezentaci posílal?" Něco spatláte a pak strávíte ještě půlku cesty dolaďováním a přemýšlením, co jste to vlastně ráno měli v hlavě.

Takže slidy by byly, co demo? Hmm, jak to znám, na demo nedojde a když, bude jiné v závislosti na dotazech. To snad ani nemá cenu chystat;). A měl jsem rpavdu, nemělo!

Klapka, jedem...

"Dovolte mi, abych vás přivítal na své přednášce. Na úvod se vás chci zeptat...ale co to plácám. Tak já se asi představím, co?" Jak vidíte, začal jsem zkušeně, tedy chci říct zmateně. Ovšem tu otázku jsem položil: "Kdo jste slyšeli o Dockeru před tím, než jste si přečetli název téhle přednášky?" Skoro všichni, fajn. "Kdo jste si ho nainstaloval?" zněla další otázka - asi 4 ruce. Uff, to zase budu plácat kraviny. Tak a poslední dotaz: "Ok, kdo jste používali kontejnery ještě před Dockerem?" Tři ruce, sakra, tak tyhle lidi ignorovat, když se budou ptát..ti jsou určitě chytří a ví toho víc než já!

Jak jsem si myslel na začátku, na pořádné demo nedošlo. Ostatně moje jediné "pořádné" demo je to, co jsme popsal v článku Running services with Docker and systemd. Takže se na něj mrkněte a demo si zkuste sami;) Třeba se vám taky rozbije, jako by se to určitě stalo mně.

Také, jako už tradičně, se přednáška zvrhla na Q&A session, kde jsem dostával záludné otázky a poskytoval jsem na ně v zásadě nesouvisející odpovědi. (Jsem v tom čím dál lepší!) Ale musím říct, že jsem si to s vámi, InstalFesťáci, užil. Hezky jsme pokecali. A navíc jste se mě nikdo nezeptal na síťování, čehož si velice cením!

Upřímně, slajdy samotné vám asi moc neřeknou, ale tady je máte - na konci jsou nějaké odkazy, tak třeba budou užitečné. Přednáška se očividně natáčela, takže jakmile bude, přihodím ještě video. A teď už dobrou noc, jdu si pustit nějaký film, když už si konečně Student Agency obnovilo výběr, a nejspíš si i trochu schrupnu. Ještě jednou díky za účast!

EDIT:

Jak jsem zjistil, video se přímo streamovalo na Youtube, takže tady je záznam přednášky:

My Docker Helpers

I work with Docker almost all the time in my job at Red Hat. Building, running, inspecting containers... Writing same long commands every time you want to run a container or get it's IP starts to annoy you quickly. That's why I started writing small helpers in the form of bash functions which are loaded through .bashrc and thus can be used from cmd line easily.

You can find them in my docker-tools repository but let me introduce them a bit.

docker-rmi-none

If you load/import/build images often, it happens that you end up having a bunch of <none> named images in your docker images output. The above commands removes them all.

docker-rm-all

I use this mostly in VMs where I am limited in terms of disk space - every container, especially when you test f.e. if yum install works, eats some space and this command lets you remove them all quickly.

dr fedora
docker run --name tmp0 -it --rm fedora bash
dr fedora cat /etc/os-release 
docker run --name tmp0 -it --rm fedora cat /etc/os-release
NAME=Fedora
...

This dr command is probably my favourite. It runs bash in the given image with arguments I use the most. You can also specifiy a command to run if you wish so.

dl [PATH_TO_]IMAGE

Simple alias for docker load command with the advantage of being able to load from default directory so you can just give it a file name and it looks in the predefined folder.

de [CONTAINER] [CMD]

The most awesome thing about using functions instead of just aliases is that you can add whatever logic you like. So my de command (representing docker exec) can be called with a container id/name and command  - same as docker exec. But it can also be called without command which then defaults to bash and also without container id/name which default to the last entry in docker ps output. If you want to skip specifying container, but still want to use different cmd than bash, use following syntax:

de "" rpm -qa

I don't use next command as often as those above but I still like it a lot - it let's you print IP address of any container. If container id/name is not specified it uses the same logic as de.

di [CONTAINER]

Last command I have on my list at the moment is dk and you could maybe guess - yes, it's docker kill and it also provides the same logic as the two above.

dk [CONTAINER]

Do you have more aliases/ideas? Let me know I am happy to make my list richer!

Delete an Image from Private Docker Registry

Have you ever wondered how to remove repositories/tags from your private Docker registry? It's simple according to Docker registry API specs. So let's try this

yum -y install docker-registry
sudo systemctl start docker-registry
docker pull fedora:21
docker tag fedora:21 localhost:5000/fedora:21 
curl localhost:5000/v1/repositories/fedora/tags/21

You should see an image id printed to your terminal. Now let's delete the image...

$ curl -X DELETE localhost:5000/v1/repositories/fedora/tags/21
true

To be clear - it does not remove the image/layers data - it just removes the reference from fedora:21 tag to the image id (i.e. data). If there is any other tag referencing the data, they will still be accessible.

Anyway, in some cases it is useful to be able to remove this reference. I run a private registry with 337 images (multiplied by few tags for every image) and I sometimes found myself in a situation where I pushed an image with wrong tag or I just wanted to stop people from pulling a specific image. I wrote a small bash script for these occasions - drrm.sh. The usage is simple

drrm.sh NAME[:TAG]

Which means for our fedora example

$ ./drrm.sh localhost:5000/fedora:21
Do you really want to untag "834629358fe214f210b0ed606fba2c17827d7a46dd74bd3309afc2a103ad0e89"? [y/N]: y
Image library/fedora:21 removed from localhost:5000

Firstly it checks if the image exists, then it asks for confirmation of removal and then it calls the previously shown curl command to delete the reference. I also have a simple "Docker Registry Garbage Collector" under development which goes through the docker-registry directory and moves unreferenced layers away (where you can delete them later). But that's going to be a topic next time:).

Why have I backed Pebble Time?

News! Awesome news! Pebble, the best smart watch maker in the world, announced new version of the watch yesterday. The name Time perfectly fits and I am proud and happy to be one of the first (thousands) backers.

I've been very interested in Pebble since their announcement on Kickstarter in 2012. I wanted to back Pebble back then but was not convinced enough. Two years later I caught myself browsing Pebble's web and hitting Buy button for basic black watch.

They arrived and I happily used them for few weeks. Then display died. I was sad so I asked Pebble what to do about it and the result was new replacement watch in a week on my hand. Awesome customer care, thank you Pebble!

Snímek z 2015-02-24 23:02:32

And here we are at the dawn of the year 2015 and I am finally backing their cool new product again on Kickstarter (Back to the roooots!) and I can't wait till May when they plan to start shipping Pebble Time. I don't need new watch, sure, but they hit the right note - color display, thinner design, new UI, possible hardware extensions... I was not thinking a single minute of switching to Android Wear from my Pebble a single minute and similarly, it took me a minute to figure out I'll back new Pebble Time. And from the numbers at Kickstarter, I was not the only one.