docker
2016-11-13
Today I learnt about Docker.
Docker is finally available for macos without needing to run linux inside virtualbox.
Docker is a wrapper around LXC.
LXC is a method for running multiple isolated linux systems ona control host using a single Linux kernel.
LXC basically combines cgroups and kernel namespaces to provide an isolated environment for each container.
How to I use it?
Download docker for your operating system here
After completeing the installation, open your terminal and type docker ps
, you should see similar output:
|
|
Now we’re ready to build our first docker image!
Building a docker image
The thing about Docker images is that they are fast. Spinning up a container is only a couple second’s work.
That’s because most of the complexity has been dealt with during the image building phase.
Building the images can take over 20 minutes in some cases, it comes down to how much work you need to do to bring your image to the desired state.
A popular approach to dealing with this is to delegate the image building to a CI server, which builds the image, runs any necessary checks before finally tagging and pushing it to a docker registry.
Once the image has been tagged, it is super simple to distribute and to run.
Create a folder for the image
Writing the Dockerfile
|
|
create the Dockerfile
|
|
The Dockerfile is teh recipe from which docker will build our image.
The easiest way to get started is to base your image off of an existing one.
For this excercise we will base our image off of the official debian image like so
|
|
Building the Dockerfile into an image
From the folder where the Dockerfile is saved, run the following command:
|
|
where khalilt/cowsay
signifies your handle khalilt
followed by the image name cowsay
Running the image
|
|
|
|