adamkdean

software engineering

Install fleetctl on OSX

By Adam K Dean on

The easiest way to install fleetctl on OSX is to use Homebrew.

If you don't already have it, install Homebrew on OSX.

Once you have it installed, install fleetctl like so:

brew install fleetctl

That simple.

rsync could not be found on your PATH

By Adam K Dean on

If you're trying to use Vagrant with Windows, and you've opted to use MinGW rather than Cygwin, you might have come across this error message when spinning up Vagrant instances:

rsync could not be found on your PATH. Make sure that rsync is properly installed on your system and available on the PATH.

This is easy to fix, when you know how.

First, install Cygwin. If you pick the x64 version, it will install by default to c:\cygwin64\. When you're installing it, and you get to select the components you wish to install, search for rsync, go to net, and click the label that says auto until it gives you a version number, such as 3.0.0 etc. Then continue with the installation of Cygwin.

Next, once this is done, in order to use MinGW rather than switching to Cygwin, we need to add the bin directory to our PATH. Navigate to the Cygwin folder, and then to the bin folder. Verify the path. For me it is c:\cygwin64\bin.

  1. Right-click on your "My Computer" icon and select "Properties".
  2. Click on the "Advanced" tab, then on the "Environment Variables" button.
  3. You should be presented with a dialog box with two text boxes. The top box shows your user settings. The bottom box shows your system settings. While you may be told not to touch your system settings, I'm going to recommend you do. I tried user settings and it didn't work. If you do this and you break it, I'm not to blame. There is my disclaimer. Don't be an idiot.
  4. Click on the PATH entry in the BOTTOM box, then click on the "Edit" button
  5. Scroll to the end of the string and at the end add the path to the bin folder you previously found. Be sure to add a semi-colon first. It could look like this:

c:\windows;c:\windows\system32 and you change that to c:\windows;c:\windows\system32;c:\cygwin64\bin etc.

Now, if you go to your MinGW terminal, and echo $PATH, you should have the new path in there. If not, try restarting the MinGW terminal. You can properly test it works by typing rsync --version:

$ rsync --version
rsync  version 3.1.0  protocol version 31
Copyright (C) 1996-2013 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    no socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, no xattrs, iconv, symtimes, prealloc

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

Now try vagrant up again. Job done?

Example Dockerfile

By Adam K Dean on

Here is an example Dockerfile. It installs nginx and adds /src to the wwwroot. Make sure that the files are 755.

# DOCKER-VERSION 0.9.1

FROM ubuntu
MAINTAINER Adam K Dean

RUN apt-get update
RUN apt-get -y install nginx

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
ADD default /etc/nginx/sites-available/default
ADD /src /var/www

EXPOSE 80

CMD ["nginx"]

FROM defines the base image.

RUN runs a command, use it to install software for example.

ADD adds local files to the container.

EXPOSE exposes a port so that the host can map a port to tunnel to it.

CMD defines the command that will be run when the container starts. There can only be one command, if there are multiple, the last one will be used. You can pass parameters to it like so:

CMD ["service", "parameter"]

Access Docker host from container

By Adam K Dean on

Docker 1.0 has just been announced, and one thing I was looking forward to was the introspection API which Solomon Hykes said was coming in 1.0. Unfortunately, it doesn't look like it has. This is a shame because it would allow the container to communicate with the host in a scoped and controlled manner.

For a small R&D project I just worked on, I had a 'gateway' container which would receive HTTP traffic and route it to other containers. For this it needed to have access to docker on the host so that it could index the containers and access their configurations, such as local IP addresses.

The way I got this to work was to install docker on the container, let's say this is the ubuntu-docker Dockerfile:

FROM ubuntu

# Install Docker
RUN apt-get install docker.io -y
RUN ln -sf /usr/bin/docker.io /usr/local/bin/docker

CMD /bin/bash

Once that's built, I mount docker.sock to the container when running it like so:

docker run -d -v /var/run/docker.sock:/var/run/docker.sock ubuntu-docker

Now if you were to run docker commands on the container, you'd actually be running them on the host. Bearing in mind that this is not a complete how to, I may write a full walkthrough if anyone needs it.

Remove all Docker containers

By Adam K Dean on

After working with Docker for only a few hours, I now have more old containers than I have fingers.

A quick and easy way to remove these is to run:

$ docker rm $(docker ps -q -a);

-q is quiet mode, which only returns container IDs.

-a is all, which as it's name suggests, returns all containers.

This will try and remove any running containers too, but that will fail.