Docker

From Edgar BV Wiki
Revision as of 09:45, 15 December 2017 by Red (talk | contribs) (→‎mariadb)
Jump to navigation Jump to search

images

list images (with containers you can start)

docker images

pull images

docker pull bitnami/mariadb:latest

containers

list containers

docker ps

stop kill container

docker stop / kill name

run a container

docker run -d -p 80:80 --name suitecrm --net=suitecrm-tier bitnami/suitecrm
docker run -e ALLOW_EMPTY_PASSWORD=yes -v mariadb_data:/bitnami bitnami/mariadb:latest

docker run populates a new container, docker start restarts a prepopulated container. ?

This is important if you get errors like "the name is already in use by container"

networks

docker network list

find which containers are using a network
<pre>
docker network inspect name

detach a network from a container

docker network disconnect networkname containername

allowing access to the containers on the bridge network from the outside

  $ sysctl net.ipv4.conf.all.forwarding

  net.ipv4.conf.all.forwarding = 0

  $ sysctl net.ipv4.conf.all.forwarding=1

  $ sysctl net.ipv4.conf.all.forwarding

  net.ipv4.conf.all.forwarding = 1

voumes

create a volume

docker volume create --label mariadb_data --name mariadb_data

list volumes

docker volume ls

view details on volume

docker volume inspect volumename

The mountpoint is what you should put in the voumes: /path/to/persistence in docker-

compose.yml

remove volume

docker volume rm volumename

Accessing a shell in a container

docker exec -it name /bin/bash


Links

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-

on-centos-7

Bitami specific

mariadb

mkdir /mariadb cd /mariadb

EITHER docker run -e ALLOW_EMPTY_PASSWORD=yes -v mariadb_data:/bitnami

bitnami/mariadb:latest

OR


vi docker-compose.yml NB Volumes mountpoint can be found using docker volume inspect mariadb_data

version: '2'

networks:
  app-tier:
    driver: bridge

services:
  mariadb:
    image: 'bitnami/mariadb:latest'
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    ports:
      - '3306:3306'
    volumes:
      - /var/lib/docker/volumes/mariadb_data/_data:/bitnami
    networks:
      - app-tier

docker-compose up -d

to set up a root password for mariadb

- MARIADB_ROOT_PASSWORD=ag63hxfd44SS3h66

instead of ALLOW_EMPTY_PASSWORD

To connect a client:

docker run -it --rm --network mariadb_app-tier bitnami/mariadb:latest mysql -h mariadb_mariadb_1 -u root

after install sudo mysql_secure_installation

Note: if you want a persistent database outside of the docker image, /var/lib/docker/volumes/mariadb_data/_data/ needs to be 777! Otherwise you get the following error:

mariadb_1 | Error executing 'postInstallation': EACCES: permission denied, mkdir '/bitnami/mariadb' For some reason this is not the case for the suitecrm_data volume.

more options at

https://github.com/bitnami/bitnami-docker-mariadb#persisting-your-database