Skip to content

Latest commit

 

History

History
104 lines (89 loc) · 2.25 KB

File metadata and controls

104 lines (89 loc) · 2.25 KB

Cheat Sheet

💡 if you got this error

Error response from daemon: cgroups: cgroup mountpoint does not exist: unknown run those two commands:

sudo mkdir /sys/fs/cgroup/systemd
sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd
  • Get the IP of the container
docker inspect app1 | grep Address

OR

docker container inspect [container_id] -f '{{.Address}}'
  • To filter the docker inspect JSON output
docker container inspect [container_id] -f '{{.property.property}}'

Useful example: to know the status of the container

docker container inspect [container_id] -f '{{.State.Status}}'
  • to do some system cleanup
docker system prune --all --force

Guides

Docker Volumes Three types of docker volumes 1️⃣ Host volumes

docker run -v /path/on/host:/path/on/container

2️⃣ Anonymous volumes

docker run -v /path/on/container

3️⃣ Named volumes (Recommended)

docker run -v name:/path/on/container

To mount a volume to a container

1️⃣ Create a volume, and try to specify an expressive name. For example, i'll create a volume to persist mysql database data.

docker volume create mysql-volume

2️⃣ Attach that volume to the mysql server container

docker run 
--name mysql-with-volume
-p 3306:3306
-e MYSQL_ROOT_PASSWORD=my-secret-pass,
OTHER_EVN_VARIABLE=other_value
-d
--mount
source=mysql-volume,
target=/var/lib/mysql
mysql

Using a bind mount We're usually using this method to sync files between the host and the container.

docker run 
--name mysql-with-volume
-p 3306:3306
-e MYSQL_ROOT_PASSWORD=my-secret-pa
-d
--mount
type=bind,
source="$(pwd)/directory-you-want-to-sync
target=/var/lib/mysql
mysql

Oracle Databse

docker  run --name oracle19c --network host -p 1521:1521 -p 5500:5500 -v /u01/oracle:/opt/oracle/oradata oracle/database:19.3.0-ee
  • Exec into the container
docker exec -ti oracle19c sqlplus system/oracle@orclpdb1

Study list

  • what linux topics to study to deeply understand docker