Docker Beta on OSX with NetBeans 8.2 workaround

The next release of NetBeans (8.2) has a cool new build-in support for Docker.

Get latest NetBeans development build here.

nb_dev
docker_beta

But since I switched to native Docker integration on my Mac the connection broke as now Docker communicates via socket instead of docker-machine URL:

unix:///var/tmp/docker.sock

NetBeans would like to get a valid http or https URL, thus this URI scheme is currently not supported:

nb_docker1

But with help of socat (e.g. via brew install socat) you can create a TCP port (e.g. 9090) listening on localhost attached to the Docker socket to establish a bidirectional connection:

socat tcp-listen:9090,fork UNIX:///var/run/docker.sock

socat

Now we are talking

nb_docker2

nb_docker3

nb_docker4

nb_docker5

nb_docker6

Links

http://wiki.netbeans.org/Docker

https://blogs.oracle.com/geertjan/entry/docker_hub_in_netbeans_ide

http://bits.netbeans.org/download/trunk/nightly/latest/

http://www.dest-unreach.org/socat/

dockerw – A simple Docker command wrapper for the rest of us

help

I am regularly working on Docker images and have to play with different settings. Thus I periodically find myself in the “build, run, clean-up, change something, re-build, run, …” rat race.

dockerw is a little tool for working with Docker images and containers. And it aims to help you (and me ;-)) to build and (locally) run Docker images while it hides all the command line pain.

Note: dockerw targets only ‘latest’ tagged images (does not impact /touch implicit tagged images)!

Usage

./dockerw [ build | run | stop | clean | status | env | help ]

Targets

Command Description
build builds the Docker image
run runs a Docker container in foreground based on the image
stop stops all running container based on the image and removes them
clean stop and then removes ALL (latest) images/artifacts<
status shows the status if the Docker image
env list current environment variables
help display help

“build”
build1[…]
build2

“run”
run

“clean”
clean

Installation

  1. Clone dockerw from GitHub.
  2. Create a dockerw directory ahead your Docker working dir and copy the dockerw.sh script to that location.
  3. Copy/create a script named “dockerw"located into the working directory of a your Docker image.

If you are using default values only: the dockerw script just calls the dockerw.sh:

#!/bin/bash
# call dockerw.sh, passing arguments and using env variables
. ../dockerw/dockerw.sh

You can overule the default environment like this:

#!/bin/bash
# env
BASE_NAME="my_container_context"
CONTAINER_NAME="my_container"
DOCKER_RUN_ARGS="-ti -p 1883:1883 -p 8883:8883"

# call dockerw.sh, passing arguments and using env variables
. ../dockerw/dockerw.sh

tree

Conventions

The CONTAINER_NAME is the parent working directory base name.
The default base name (BASE_NAME_DEFAULT) and default docker run arguments (DOCKER_RUN_ARGS_DEFAULT) can be changed in dockerw/dockerw.sh.
The image name (IMAGE_NAME) is build like this: BASE_NAME_DEFAULT/CONTAINER_NAME (e.g. jerady/ubuntu).

Environment Variables

the name of the docker image”${`BASE_NAME`}/${`CONTAINER_NAME`}”jerady/mosquitto

Name Description Default Example
BASE_NAME the base name of the Docker container jerady jerady
CONTAINER_NAME the name of the Docker container $(`basename 'pwd'`) mosquitto
IMAGE_NAME the name of the Docker image ${BASE_NAME}/${CONTAINER_NAME} jerady/mosquitto
DOCKER_RUN_ARGS the arguments to run the container -ti -ti
DOCKER_RUN the docker run command to be called by ./dockerw run docker run ${DOCKER_RUN_ARGS} --name ${CONTAINER_NAME} ${IMAGE_NAME} docker run -ti --name mosquitto jerady/mosquitto

I added two example Docker images/projects to show how the custom dockerw script can be implemented, e.g. this simple script for mosquitto:

#!/bin/bash

# env variables
DOCKER_RUN_ARGS="-ti -p 1883:1883 -p 8883:8883"

. ../dockerw/dockerw.sh

leads to these implicit values:
env

GitHub

dockerw project on GitHub