Showing posts with label docker. Show all posts
Showing posts with label docker. Show all posts

Tuesday, November 16, 2021

macOS: Docker volumes and Minikube

This morning I decided to replace Docker Desktop on my mac with the Hyperkit + Minikube combo like explained in Run Docker without Docker Desktop on macOS.

Volumes

However, some file mounted through a volume in docker-compose invariably resulted in a directory being created in the container instead of a file.
docker-compose.yaml

version: "3.8"
services:
  postgres:
    container_name: oss-postgres
    image: postgres:14-alpine
    stdin_open: true
    tty: true
    restart: always
    ports:
      - 5432:5432
    volumes:
      - ./postgres/postgres.sh:/docker-entrypoint-initdb.d/postgres.sh
    environment:
      POSTGRES_PASSWORD: "xxx"
logs
oss-postgres  | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/postgres.sh
oss-postgres  | /usr/local/bin/docker-entrypoint.sh: line 169: /docker-entrypoint-initdb.d/postgres.sh: Is a directory
oss-postgres exited with code 126
It appears that the volumes need being created in the Minikube VM beforehand (source: Replace Docker Desktop with Minikube and Hyperkit on macOS), like in:
> minikube stop
> minikube start --mount --mount-string="/Users/jerome/src/boss/:/Users/jerome/src/boss/" --memory 4096 --cpus 4

Ports

Any service previously reachable through localhost by port forwarding is now available by using docker.dev, mapped to minikube ip in /etc/hosts. 

NOTE

Never use .local domain on macOS, or DNS resolving will become awfully slow: use for ex. docker.dev instead of docker.local for the hostname of the minikube ip, contrary to what the 1st article proposes.

Monday, June 15, 2020

PgBouncer: WARNING DNS lookup failed: host.docker.internal: result=0

If you're using PgBouncer in a Docker container and try to connect to the host via host.docker.internal, you may experience this error:
2020-06-15 17:23:46.211 UTC [1] WARNING DNS lookup failed: host.docker.internal: result=0
This fix resolves it: Fix DNS for Docker #8

Thursday, May 14, 2020

Docker Alpine Linux: ssh keeps asking for password

Suppose we are running an sshd Docker Alpine (3.11) container. Even if properly configured by installing an SSH public key for root, you may keep being prompted for the root password by sshing the container.
[jerome@jeroboam] > docker run -e 'SSH_PUBLIC_KEY="..." -it --rm -p 2223:22 --name ss-ussd-sshd ss-ussd/sshd
[jerome@jeroboam] > ssh -p 2223 root@localhost
Warning: Permanently added '[localhost]:2223' (ECDSA) to the list of known hosts.
root@localhost's password: 
Solution: can't config ssh service when i use alpine:3.9 #28
Root cause: CVE-2019-5021

Bottom line: add this command in the Dockerfile:
# make sure root login is disabled
RUN sed -i -e 's/^root::/root:!:/' /etc/shadow

Friday, December 21, 2018

Github: retrieve individual files from Github in a Dockerfile

FROM alpine:edge

ARG githubtoken=1852...

RUN apk add --no-cache curl wget

RUN curl -o /var/mbqt/lib/MBQT/Bootstrap.pm -H "Authorization: token $githubtoken" -H 'Accept: application/vnd.github.v3.raw' -L https://api.github.com/repos///contents/perl/lib/MBQT/Bootstrap.pm

Wednesday, December 12, 2018

Docker: difference between container and image

Source: In Docker, what's the difference between a container and an image?
See explanation from cbare: "Images are frozen immutable snapshots of live containers..."

Wednesday, June 20, 2018

Clojure: create a Clojure docker

Use case: I need to run some Clojure tests that use a library depending on glibc 2.14.
Unfortunately, I use CentOS 6.9 that relies on glibc 2.12, that cannot be updated.
Solution: Use a Docker file to run the Clojure tests.

Source: https://store.docker.com/images/clojure
docker pull clojure
  • Dockerfile
  • FROM clojure
    RUN mkdir -p /usr/src/app
    WORKDIR /usr/src/app
    COPY project.clj /usr/src/app/
    RUN lein deps
    COPY . /usr/src/app
    RUN lein uberjar
    CMD ["lein", "test"]
  • docker.build.sh
  • set -x
    cd ~/av-usage
    cp ~/tmp/clojure/docker/Dockerfile Dockerfile.test
    docker build -f Dockerfile.test -t av-usage-test .
    rm Dockerfile.test
  • docker.run.sh
  • set -x
    docker run -it --rm --name my-av-usage-test av-usage-test