Docker – to be continued

Building from Dockerfile

docker build [directory with Dockerfile]

Example Dockerfile:

FROM fedora:25

RUN dnf install -y java-1.8.0-openjdk git maven mc vim unzip \
&& cd /tmp && git clone https://github.com/wildfly-swarm/wildfly-swarm swarm

WORKDIR /tmp/swarm

ENTRYPOINT mvn clean install

FROM specifies a parent image

RUN specifies a command that is run during the image build. The results of the command are stored in the image.
One can put multiple RUNs in a Dockerfile, but each will result in a new layer/image. It makes sense if you have a part of RUN that you are unlikely to modify. This will result in reusing of the layer from the first build in the consecutive builds, thus speeding up your work.

ENTRYPOINT is executed after container start. It is executed regardless of any command provided by docker run.
If you don’t want to run the start-up code in the case a user provides some run command, use CMD instead.
One can mix ENTRYPOINT with CMD, more details about the two: http://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/

Running

docker run [image name]

To get into container’s bash:

docker run -it [image name] bash

To resurrect a container:
commit a stopped container:

docker commit [container sha] tmp

Start the container (in the example below, overriding entrypoint, because it was already ran):

docker run -ti --entrypoint=/bin/bash tmp

Sharing files between host and container

Mounting a host directory into a container:

docker run -v [host directory]:[container directory] [image name]

Copying files from docker to host (may be working both ways in new versions):

docker cp [container]:[container file/directory] [host target]
Advertisements

phantom This application failed to start because it could not find or load the Qt platform plugin “xcb”.

If you encounter this issue, it’s a bug in phantomjs that prevents it from working properly when QT_QPA_PLATFORM environment variable is set.

The best way to solve this issue is to upgrade to the newest phantom, but if you cannot do it, you can unset the variable:
unset QT_QPA_PLATFORM
or give it an empty value, e.g.:
export QT_QPA_PLATFORM=""

If you don’t want to type the command every time, you can one of the above to .bashrc or .profile

Here’s one of the related issues on GitHub: https://github.com/ariya/phantomjs/issues/14061

Invoking angular stuff from console

To get an angular service in chrome console you can use:

angular.element(document.body).injector().get('serviceName')

This will get you a service object.

Source: http://stackoverflow.com/questions/15527832/how-can-i-test-an-angularjs-service-from-the-console

To get to angular scope, inspect an element, for which you want to get the scope and invoke: angular.element($0).scope()

(http://stackoverflow.com/questions/13743058/how-to-access-the-scope-variable-in-browsers-console-using-angularjs)

PostgreSQL on Fedora: psql: FATAL: Ident authentication failed for user “username”

Usually, to add a user to postgres, you have to run psql as user postgres and create user as such.

On Ubuntu it’s enough to let you log in as a newly created user to the DB, but it’s not enough on Fedora. Here psql responds with the error from the subject.

To fix it add the following line to pg_hba.conf (on F23: /var/lib/pgsql/data/pg_hba.conf):

local   all             all                           md5

Line above is for socket configuration. If you need IP access too, add:

host    all             all        127.0.0.1/32       md5