Docker

Attach without signal forwarding

1
  docker attach --sig-proxy=false <CONTAINER-ID>

Detach from container

C-p C-q

Grep logs

1
  docker logs 2>&1 | grep hello

Assign IP address

1
2
  docker network create --subnet=172.18.0.0/16 gophernet
  docker run --net gophernet --ip 172.18.0.22 -it ubuntu bash

Trouble running Docker

Running dlv inside a docker container

Alright, so you're running within a Docker container. Docker has security settings preventing ptrace(2) operations by default with in the container. Pass —security-opt=seccomp:unconfined to docker run when starting.

https://github.com/derekparker/delve/issues/515

Running arm containers on Ubuntu

1
2
  sudo apt install qemu qemu-user-static binfmt-support
  sudo update-binfmts --enable qemu-arm

Mount qemu-arm-static binary inside the container.

1
  docker run -it --rm -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static philipz/rpi-raspbian bash

Docker Compose

https://docs.docker.com/compose/compose-file/

Expose port

1
2
  expose:
    - "CONTAINER"

Publish port

1
2
  ports:
    - "HOST:CONTAINER"

Install packages via apt-get

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
  RUN apt-get update && apt-get install -y \
      aufs-tools \
      automake \
      build-essential \
      curl \
      dpkg-sig \
      libcap-dev \
      libsqlite3-dev \
      mercurial \
      reprepro \
      ruby1.9.1 \
      ruby1.9.1-dev \
      s3cmd=1.1.* \
   && rm -rf /var/lib/apt/lists/*

https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run