My Docker Cheat Sheet

Software Engineer at BMW, Oracle Certified Professional Java SE 11 Developer
Search for a command to run...

Software Engineer at BMW, Oracle Certified Professional Java SE 11 Developer
No comments yet. Be the first to comment.
Two whole days of my life, down the drain! Thankfully, it was just my pet project, but I ended up sacrificing an entire weekend wrestling with this enigma. So, I'm writing this blog post to save you from the same fate. Problem: I am using Quarkus and...

Shebang Shebang is a combination of bash # and bang ! followed the the bash shell path. Shebang is simply an absolute path to the bash interpreter. #! /bin/bash Make a file executable To make a .sh file executable only for your user, use: chmod u+x...

1. Show tables The command \dt stands for describe tables and shows all tables in the database, equivalent to show tables in MySQL. \dt 2. Create user Run the following SQL command to create a user. Replace and 'password' with the desired username a...

How to set JAVA_HOME on macOS Monterey? First check which shell you are using (either bash or zsh). For zsh shell, we can put the environment variables at ~/.zshenv or ~/.zshrc.echo $SHELL /bin/zsh On Mac OS X 10.5 or later, we can use /usr/libexe...

Fork your open source project you want to contribute into your GitHub and clone your fork. git clone git@github.com:dcnis/mockito.git Show current configured remote repositories. The origin repo points to your fork on GitHub. git remote -v > origin ...

This is a collection of some Docker statements. Mainly for myself to copy-paste and save time.

root directory, create following files.
├── scripts/
│ ├── schema.sql
│ ├── data.sql
│ └── mycustom.cnf
└── docker-compose.yml
Edit yourdocker-compose.yml as follows
version: "3.8"
services:
db:
image: mysql:8.0.33
container_name: mysql8.0.33
restart: always
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: playground
volumes:
- "./scripts/schema.sql:/docker-entrypoint-initdb.d/1.sql"
- "./scripts/data.sql:/docker-entrypoint-initdb.d/2.sql"
- "./scripts/mycustom.cnf:/etc/mysql/conf.d/custom.cnf"
ports:
- 3306:3306
adminer:
image: adminer
restart: always
ports:
- 8080:8080
scripts/schema.sqlCREATE TABLE `test` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(32) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
scripts/data.sqlINSERT INTO test (name)
VALUES ("Dennis");
docker-composedocker-compose up
localhost:8080, login to your MySQL instance and have fun.docker exec -t -i <container_name> /bin/bash
-t (terminal): This option allows you to interact with the container using a terminal-like interface. It is commonly used when you need to run interactive commands inside the container, such as an interactive shell session.
-i (interactive): This option enables you to provide input to the command running inside the container.
docker exec -t -i <container_name> mysql -u my_user -p
docker cp <container-id>:/file/path/within/container /host/file/path/target
docker push dcnis/popup-chinese-backend-quarkus:tagname
dcnis/popup-chinese-backend-quarkus. So first we have to create a new tag.List docker images
docker images
quarkus/popup-chinese-backend-quarkus
We can see we have one images with the name quarkus/popup-chinese-backend-quarkus. Based on this image, we create the new tag.
Create a new tag from your existing docker image.
docker tag quarkus/popup-chinese-backend-quarkus dcnis/popup-chinese-backend-quarkus
docker images
quarkus/popup-chinese-backend-quarkus latest
dcnis/popup-chinese-backend-quarkus latest
% docker push dcnis/popup-chinese-backend-quarkus
Using default tag: latest
The push refers to repository [docker.io/dcnis/popup-chinese-backend-quarkus]
48efe9a978d6: Pushed
5f77935eec15: Pushed
3b6ba2682483: Pushed
129f98c51b7a: Pushed
41c90dc5a18e: Pushed
5f70bf18a086: Pushed
5282f3464e78: Pushed
latest: digest: sha256:0baf3b80fdc4ea7fd73f199f88d8c91099e3191ca8705dd0e79d68dd67013d01 size: 1780
% docker build -f src/main/docker/Dockerfile.native-micro -t dcnis/popup-chinese-backend-quarkus .
% docker push dcnis/popup-chinese-backend-quarkus
docker run --name postgresql -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres