-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-containers.html
101 lines (86 loc) · 5.4 KB
/
docker-containers.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Docker containers</title>
<link rel="stylesheet" href="./theme/css/main.css" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body id="index" class="home">
<a href="https://github.com/henriquemiranda">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub" />
</a>
<header id="banner" class="body">
<h1><a href="./">Henrique Miranda</a></h1>
<h3>Physics, Materials science... with python, C, Fortran and Javascript</h3>
<nav><ul>
<li><a href="./index.html">About Me</a></li>
<li class="active"><a href="./category/computers.html">Computers</a></li>
<li><a href="./category/materials-science.html">Materials science</a></li>
<li><a href="./category/others.html">Others</a></li>
</ul></nav>
</header><!-- /#banner -->
<section id="content" class="body">
<article>
<header>
<h1 class="entry-title">
<a href="./docker-containers.html" rel="bookmark"
title="Permalink to Docker containers">Docker containers</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2017-04-19T14:11:00+02:00">
Published: Wed 19 April 2017
</abbr>
</footer><!-- /.post-info --> <p>The first time I heard about <a href="https://www.docker.com/">docker</a> containers I thought: "Well this is a great idea!".
When I tried to install them, however, I gave up.
The biggest problem was the time it takes to get the containeers up and running.
For someone whose job is to deploy software this is a great help but simpler applications the overhead is not be worth the benefit.</p>
<p>This excuse stopped to make sense when I tried to configure <a href="https://travis-ci.org/">Travis-CI</a> for <a href="https://github.com/henriquemiranda/yambopy">yambopy</a>.
Travis-CI is a great tool to test software in an automatic way, you should check it out.
Talking from my little personal experience, if you have your
code hosted on github you can get the basic setup of Travis-CI running with a couple of clicks.
To configure the tests and to get them to run is, however, a much more difficult problem.
At some point I will write here about that as well.</p>
<p>Now you might ibe wondering what is the relation between Travis-CI and docker?
The connection came when I tried to setup the environment to run the yambopy test suite in Travis-CI.
I looked how I could run the Travis-CI environment locally, and found this <a href="http://stackoverflow.com/questions/21053657/how-to-run-travis-ci-locally">post</a> in StackOverflow.</p>
<p>There I realized that the images used by Travis-CI to run the different environments are available in
<a href="https://quay.io/organization/travisci">Quay.io</a>.
I decided then to try to run the container on my local machine to make sure everything works properly.
This helped to write the <code>travis.yaml</code> file needed by Travis-CI. Here is a short description of the steps I took.</p>
<p>First you need to install <code>docker</code> and <code>docker-machine</code> on your computer.
In my case since I have a Mac with OSX and macports I just typed:</p>
<div class="highlight"><pre><span></span><code>sudo port install docker-machine docker-compose docker
</code></pre></div>
<p>Then you need to start the <code>docker-machine</code>:</p>
<div class="highlight"><pre><span></span><code>docker-machine start
</code></pre></div>
<p>Then download the image you want to use:</p>
<div class="highlight"><pre><span></span><code>docker run -it quay.io/travisci/travis-python /bin/bash
</code></pre></div>
<p>And login in to it.
Now you are inside an operating system running on a docker container.
You can install your software in it and make sure it runs.</p>
<p>One important distinction is the difference between images and containers.
Images contain the operating system and are static.
Containers are virtual systems that start from the image but contain all the changes on top of the image to bring the environment to the current state.
To run a container in another computer, you download the image in that computer, and move the container there.
If you don't want to move the container around you can distribute the dockerfile that contains the recipe to build the container from the image.</p>
<p>This simple idea of running applications on virtual environments offers many possibilities.
I will come back to this topic with more details about my personal experience.</p>
</div><!-- /.entry-content -->
</article>
</section>
<section id="extras" class="body">
</section><!-- /#extras -->
<footer id="contentinfo" class="body">
<address id="about" class="vcard body">
Proudly powered by <a href="http://getpelican.com/">Pelican</a>, which takes great advantage of <a href="http://python.org">Python</a>.
</address><!-- /#about -->
<p>Theme based on <a href="http://coding.smashingmagazine.com/2009/08/04/designing-a-html-5-layout-from-scratch/">Smashing Magazine</a></p>
</footer><!-- /#contentinfo -->
</body>
</html>