Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Docker Cheat Sheet

Docker Cheat Sheet

Testing with goss and dgoss

On the Mac

  1. install goss

    curl -L https://github.com/aelsabbahy/goss/releases/download/v0.3.7/goss-linux-amd64 -o /usr/local/bin/goss
    curl -L https://raw.githubusercontent.com/aelsabbahy/goss/master/extras/dgoss/dgoss -o /usr/local/bin/dgoss
    chmod +rx /usr/local/bin/dgoss
    
  2. add the following line to your ~/.profile or .zshrc

    export GOSS_PATH=/usr/local/bin/goss
    
  3. within the directory that contains your Dockerfile (where you want to create a goss.yml with tests) run

    dgoss edit -p 8080:80 <IMAGE NAME>
    
  4. add some checks with goss a ... and quit the editor with exit

    goss a port 80
    goss a http http://localhost
    exit
    
  5. run the tests against the container with

    dgoss run <IMAGE NAME>
    

Docker in Docker on Mac

  1. Create a Docker image that contains the docker binary

    FROM ...
    
    RUN apt-get update
    RUN apt-get -y install docker.io
    
    ENV GOSS_PATH="/usr/local/bin/goss"
    ENV GOSS_FILES_STRATEGY="cp"
    
  2. Start a container and mount the docker socket and install docker binary

    mkdir /tmp/docker
    docker run -it -v /var/run/docker.sock:/var/run/docker.sock - /tmp/docker:/tmp <IMAGE NAME>
    

Resources

Docker Testing

Docker Administration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.