Monday, April 01, 2019

Failed to Link Error When Building Postgresql Docker Image

Symptom:

   When we build docker image for Postgresql 9.2  9.5 on Oracle Linux 7, we hit below error

failed to link /usr/share/man/man1/clusterdb.1 -> /etc/alternatives/pgsql-clusterdbman: No such file or directory
failed to link /usr/share/man/man1/createdb.1 -> /etc/alternatives/pgsql-createdbman: No such file or directory
.......

Solution:

It is due to base image Oracle linux does not have such directory (to save space for linux image)   /usr/share/man/man1/ 
Add below to Dockerfile to workaround it
RUN mkdir -p /usr/share/man/man1

The full Dockerfile details of Postgresql 9.5 is on github link

Simple GO Codes Functions

Golang  function to fill a specific default value into an Array
Simple code to achieve that

func filldefault(YourArray []int ) {
   for i := range YourArray { YourArray[i] = -1 }
}

Golang function of max and min
Simple code to achieve that

func max(x, y int) {
   if x > y {
        return x
   } else {
       return y
        }
}

func min(x, y int) {
   if x > y {
        return y
   } else {
       return x
       }
}

Golang  function of contain or find an element in an array
Simple code to achieve that

func contain(t []int, x int) bool {
       for _, n := range t {
        if n == x {
          return true
       }
     }
   return false

}

Dockerfile for Httpd on Oracle Linux 7

Please check details on Github OracleLinux Httpd Dockerfile Repo

Dockerfile for Postgresql9.5 on Oracle Linux 7

Please check details on Github OracleLinux Postgresql 9.5 Dockerfile 

Docker: Failed to get D-Bus connection: Operation not permitted

Symptom:

When we build Postgresql 9.5 docker image on  Oracle Linux 7-slim ( FROM oraclelinux:7-slim)
it error out
Docker: Failed to get D-Bus connection: Operation not permitted

Solution:

It is due to Oracle Linux 7-slim is very slim. It takes systemd function out of the image.  D-bus need systemd to function.  In order to fix it ,we need to use a bit heavy linux image which includes systemd.  To use Oracle Linux 7 would fix it (FROM oraclelinux:7)

The full Dockerfile details of Postgresql 9.5 is on github link