Wednesday, December 05, 2018

docker: Error response from daemon: OCI runtime create failed:


$ docker run -i -t a4a9a769aa01 /bin/bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown.


$ docker run -i -t a4a9a769aa01 sh

Docker Compose Version 2 and 3

Docker Compose file structure for version 3 is the same as version 2. Some of the items in version 2 are removed in version 3. For more details: Docker Compose File Upgrade

Docker Networking Basics

$ docker version
Client: Docker Engine - Community
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:47:43 2018
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:55:00 2018
  OS/Arch:          linux/amd64
  Experimental:     true
$ docker-compose version
docker-compose version 1.23.2, build 1110ad01
docker-py version: 3.6.0
CPython version: 3.6.6
OpenSSL version: OpenSSL 1.1.0h  27 Mar 2018
$ docker network

Usage: docker network COMMAND

Manage networks

  connect     Connect a container to a network
  create      Create a network
  disconnect  Disconnect a container from a network
  inspect     Display detailed information on one or more networks
  ls          List networks
  prune       Remove all unused networks
  rm          Remove one or more networks

Run 'docker network COMMAND --help' for more information on a command.
$ docker network ls
NETWORK ID          NAME                   DRIVER              SCOPE
2ecc545ad2b8        alpy_default           bridge              local
d8671393ed7e        bridge                 bridge              local
b3c19c5fabc5        host                   host                local
861cdc4e1aaa        kafk_default           bridge              local
43c34d2fd46b        kafka-docker_default   bridge              local
4436df0f00b3        none                   null                local
7b3893e43bb7        rmoff_default          bridge              local

$ docker network inspect kafk_default
        "Name": "kafk_default",
        "Id": "861cdc4e1aaaed3e874a93e0153fdf2eeaabb9a81c84fe246c0db1e83408abbb",
        "Created": "2018-12-04T23:38:29.1987718Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                    "Subnet": "",
                    "Gateway": ""
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        "ConfigOnly": false,
        "Containers": {},
        "Options": {},
        "Labels": {}

$ docker info
Containers: 20
 Running: 4
 Paused: 0
 Stopped: 16
Images: 48
Server Version: 18.09.0
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
  Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952GiB
Name: linuxkit-025000000001
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 51
 Goroutines: 82
 System Time: 2018-12-05T17:17:10.0243027Z
 EventsListeners: 3
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Experimental: true
Insecure Registries:
Live Restore Enabled: false
Product License: Community Engine

Docker on Mac. Version is most recent than Docker Networking course by Nigel Poulton.

Tuesday, December 04, 2018

How to find Docker host IP

On Mac:

$ docker run -it busybox /bin/sh

Inside the container:

/ # pwd
/ # ping docker.for.mac.localhost
PING docker.for.mac.localhost ( 56 data bytes
64 bytes from seq=0 ttl=37 time=6.215 ms
64 bytes from seq=1 ttl=37 time=0.698 ms
64 bytes from seq=2 ttl=37 time=0.423 ms
64 bytes from seq=3 ttl=37 time=0.324 ms
64 bytes from seq=4 ttl=37 time=0.647 ms
--- docker.for.mac.localhost ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 0.324/1.661/6.215 ms

On Mac:
$ export HOST_IP=
$ echo $HOST_IP
$ docker run --add-host outside:$HOST_IP --name busybox -it busybox /bin/sh
/ # cat /etc/hosts localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters outside b0d28743cbcb


Friday, November 30, 2018

ERROR: could not find idn library!

CentOS issue resolution:

wget -q tar xfz libidn-1.35.tar.gz

tar xfz libidn-1.35.tar.gz

cd libidn-1.35/
make install


make: g++: Command not found

yum groupinstall 'Development Tools'

Friday, November 23, 2018

Active Class Does not Highlight in Bootstrap

For some reason, the Bootstrap active class was not highlighting the tab in Rails project. The workaround:

Use style='background-color: #5e5e5e' or use application helper:

style='<% active_background(account_path) %>'

Friday, November 16, 2018

Simple Dockerfile and docker-compose.yml for Rails 5 App

Dockerfile contents:

FROM ruby:2.5

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs

RUN mkdir /budget
WORKDIR /budget

COPY Gemfile /budget/Gemfile
COPY Gemfile.lock /budget/Gemfile.lock

RUN bundle install
COPY . /budget

LABEL maintainer="Bala Paranj "

CMD puma -C config/puma.rb


version: '3'
    build: .
    command: bundle exec rails s -p 3000 -b ''
      - "3000:3000"


docker-compose build
docker-compose up

Simple CircleCI Configuration File to Build Rails 5 Project

I am working on the landing page for Budget Scape. Here is the simplest circleci/config.yml:

version: 2
    working_directory: ~/budget
      - image: circleci/ruby:2.4.1
          RAILS_ENV: test
      - checkout

      - run: sudo apt-get update && sudo apt-get install nodejs
      # Bundle install dependencies
      - run: bundle install

      # Run the tests
      - run: bundle exec rake

I am using sqlite as the production database.  The home page is a lead capture page with bullet list of benefits for a user.

Wednesday, November 07, 2018

Developing REPL from Scratch in Ruby

Read Evaluate Print Loop

One liner:

loop { p eval gets }


loop do
  print "$ "
input = gets.chomp!
result = eval(input)
puts "=> #{result}"

Persist Local Variable

myirb_binding = binding()
loop do
  print "$ "
input = gets.chomp!
result = myirb_binding.eval(input)
puts "=> #{result}"

Code written by Chris Wanstrath:

loop do
  print ENV['REPL_PROMPT'] || "#{ARGV[0]}>> "

    line = $stdin.gets.chomp
  rescue NoMethodError, Interrupt

  if from_stdin
    run = "echo \"%s\" | #{command}" % [ line, nil ]
    run = "#{command} %s" % [ line, nil ]
  puts "$ #{run}" if debug
  system run
  warn "Use Ctrl-D (i.e. EOF) to exit" if line =~ /^(exit|quit)$/

Difference Between IRB and Code in Ruby File

One of the differences is that any method defined at the top level in a Ruby file becomes a private method in Object.

def greet
  p 'hi'

o =

NoMethodError: private method ‘greet’ called for #. You can verify this:

 def greet
   p 'hi'

 p self.private_methods.grep(/greet/)

But in IRB it becomes a public method.

$ irb
2.3.3 :001 > def greet
2.3.3 :002?>   p 'hi'
2.3.3 :003?>   end
 => :greet
2.3.3 :004 > o =
 => # 
2.3.3 :005 > o.greet
 => "hi"
Hey, you can also use self to call the greet method like this:


or just


Tuesday, November 06, 2018

Moving a Repo Quickly from Gitlab to Github

If you don't mind losing the git log in the new repo, you can move a repo easily in three steps:

1. Remove the existing git files in the repo:

rm -rf .git

2. Add a new origin:

git remote add new-origin

3. Push it to the new repo

git push --all new-origin

Managing SSH Keys in Ubuntu

sudo apt-get install keychain

In ~/.bashrc, add:

keychain id_rsa
. ~/.keychain/`uname -n`-sh

In the terminal:

source ~/.bashrc

 * keychain 2.8.2 ~
 * Found existing ssh-agent: 5059
 * Known ssh key: /home/bparanj/.ssh/id_rsa

I had already generated the ssh key using ssh-keygen and ran:

$ eval "$(ssh-agent -s)"
Agent pid 5059