Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mryechkin/ace164acf3ae284c2bb4ba6ce5c93a18 to your computer and use it in GitHub Desktop.
Save mryechkin/ace164acf3ae284c2bb4ba6ce5c93a18 to your computer and use it in GitHub Desktop.
Docker for the Impatient

aka "Let's take some notes about using Docker on Mac OS X to turn deployment of Scala applications into a much better experience."

DISCLAIMER The doc is a compilation of different articles and videos found on the Internet. Almost nothing's mine - mostly layout. See CREDITS section below to know who to praise. All mistakes are mine and are not intended. Drop me an email at jacek@japila.pl if you spot any errors or just share what you think about the doc.

The document lives at https://gist.github.com/jaceklaskowski/ca55be80cb76e84ce478

Intro

I'm on Mac OS X and so you're going to see a lot of setup tweaks for the platform that are not necessarily needed for your environment, esp. Linux one. When you see boot2docker and you're on Linux, just disregard the line or even entire paragraph.

Docker doesn't run directly on OS X and on Windows and that's why you need boot2docker that is just a tiny core of Linux to have environment with things required to run Docker - lxc, cgroups and others (highly advanced)

There's Docker Hub to host Docker images (just like GitHub for social coding). Pick one image and start it off right away using:

docker run --rm user/image

where user is the owner of the image on Docker Hub.

docker secret

docker system

$ docker system df
$ docker system prune
$ docker system prune -a    // deep clean

docker volume

$ docker volume ls

Working inside a Docker container

You can work in the Docker container using:

docker exec -it <container name> /bin/bash

Docker sample - Easy deployment of Apache Kafka using Docker

This part was published as a blog post Apache Kafka on Docker as part of a larger project to explore the features of Apache Kafka.

Docker sample - Artifactory on Docker

There are different ways to run Artifactory on your laptop. You may pull down zip or rpm files and install them on your local workstation. Or you could merely docker pull the latest Docker image of Artifactory and give it a go without messing the local workstation up (at least not that much as installing it on your OS directly).

Consult Artifactory as a Docker Image.

  1. boot2docker up unless you've done it already.

  2. $(boot2docker shellinit) to set up the terminal.

  3. Execute docker pull jfrog-docker-registry.bintray.io/artifactory/artifactory-oss to download Artifactory OSS's Docker image.

     ➜  ~  docker pull jfrog-docker-registry.bintray.io/artifactory/artifactory-oss
     Pulling repository jfrog-docker-registry.bintray.io/artifactory/artifactory-oss
     22a955eb08d4: Pulling dependent layers
     511136ea3c5a: Download complete
     5b12ef8fd570: Download complete
     ...
     091320beb869: Download complete
     c33fb0470c44: Download complete
     8d466d99a7ce: Download complete
     Status: Downloaded newer image for jfrog-docker-registry.bintray.io/artifactory/artifactory-oss:latest
    
  4. docker run --rm --name artifactory -p 8081:8081 -p 80:80 -t jfrog-docker-registry.bintray.io/artifactory/artifactory-oss

     ➜  development_environment git:(DS-880-ansible) ✗ docker run --rm --name artifactory -t jfrog-docker-registry.bintray.io/artifactory/artifactory-oss
     Starting nginx:                                            [  OK  ]
     Starting Artifactory tomcat as user artifactory...
     ...
     ###########################################################
     ### Artifactory successfully started (8.133 seconds)    ###
     ###########################################################
    
  5. docker ps to see the Artifactory container's status

     ➜  development_environment git:(DS-880-ansible) ✗ docker ps
     CONTAINER ID        IMAGE                                                          COMMAND                CREATED              STATUS              PORTS                                                 NAMES
     4cf495405166        jfrog-docker-registry.bintray.io/artifactory/artifactory-oss   "/tmp/runArtifactory   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp, 0.0.0.0:8081->8081/tcp, 443/tcp   artifactory
    
  6. Enter Artifactory's using http://localhost/artifactory. If you are running on a Windows or Mac systems using boot2docker you need to use DOCKER_HOST IP instead of localhost, i.e. boot2docker ip.

  7. You may also access the shell of the container using docker exec -it artifactory /bin/bash.

     ➜  ~  docker exec -it artifactory /bin/bash
     [root@eb7e727e5b36 /]#
    

    Please restrain yourself from modifying the container as the idea of Docker containers is that they're immutable once booted up and any changes should rather be done at their definition.

Docker and GitHub

  1. Create docker-whatever repo on GitHub with Dockerfile and README.md.
  2. Run docker run -td -p 8000:8000 paimpozhil/docker-mist to use the image from Docker Hub.
  3. Use 8000 as if you ran the app on the bare metal of your local workstation.

If you however want to customize the Docker-based offering, git clone the repo and tweak Dockerfile that comes with it:

  1. git clone https://github.com/paimpozhil/docker-mist.git
  2. cd docker-mist
  3. docker build -t mistio .
  4. docker run -td -p 8000:8000 mistio

Enter the shell of a given container using docker run -ti -p 8000:8000 mistio /bin/bash. Note the /bin/bash as the last parameter that gives you the entry point to the running container.

Credits (aka who to praise while only me to blame)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment