TL;dr

docker run examples

phpmyadmin


docker network create some-network;

docker run -d --restart always --network some-network \
--name phpmyadmin1 \
-p 11980:80 \
-e PMA_ARBITRARY=1 \
phpmyadmin/phpmyadmin:5.0.2;

docker run -d --restart always --network some-network \
--name=mysql1 \
-p 13306:3306 \
-e MYSQL_ROOT_PASSWORD=abc123456 \
mysql:5.7.29;

docker run -d --restart always --network some-network \
--name=adminer1 \
-p 11981:8080 \
adminer:4.7.6;


docker rm -f phpmyadmin1 mysql1 adminer1

registry

docker run -d -p 5000:5000 --restart always --name registry -v /tmp/registry:/var/lib/registry registry:2.7

docker pull debian:10
docker tag debian:10 localhost:5000/debian:10
docker push localhost:5000/debian:10

tomcat

docker run -it --rm \
--name tomcat2 \
-p 8088:8080 \
--env JAVA_OPTS='-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true' \
tomcat:9.0.34-jdk14-openjdk-buster

gitbook

git clone https://github.com/fwhezfwhez/test_gitbook.git book
docker run -it --rm --name gitbook -v $(pwd)/book:/srv/gitbook -p 14000:4000 -p 35729:35729 fellah/gitbook:3.2.1

mdbook

cd /path/to/book
docker run --rm -v $(pwd):/data -u $(id -u):$(id -g) -it hrektts/mdbook mdbook init
docker run --rm -v $(pwd):/data -u $(id -u):$(id -g) -it hrektts/mdbook mdbook build
docker run --rm -p 3000:3000 -p 3001:3001 -v $(pwd):/data -u $(id -u):$(id -g) -it hrektts/mdbook mdbook serve -p 3000 -n 0.0.0.0
# GitBook 使用 SUMMARY.md 文件作为书籍的目录结构,可以用来制作书籍目录。


# Summary
* [Introduction](README.md)
* Part I
    * [从命令行进行测试](Chapter1/CommandLine.md)
    * [Monkey](Chapter1/Monkey.md)
    * [monkeyrunner 参考](Chapter1/MonkeyrunnerReference.md)
        * [概览](Chapter1/MonkeyrunnerSummary.md)
        * [MonkeyDevice](Chapter1/MonkeyDevice.md)
        * [MonkeyImage](Chapter1/MonkeyImage.md)
        * [MonkeyRunner](Chapter1/MonkeyRunner.md)
* Part II
    * [Introduction](Chapter2/c1.md)
    * [Introduction](Chapter2/c2.md)
    * [Introduction](Chapter2/c3.md)
    * [Introduction](Chapter2/c4.md)

http

docker run -p 8000:8000 -it python:3.7-slim python3 -m http.server --bind 0.0.0.0
curl -v http://127.0.0.1:8000

nginx-php-fpm

cat > $(pwd)/default.conf <<'EOF'
server {
    listen   80;
    server_name localhost;

    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    sendfile off;
    server_tokens off;

    error_log /dev/stdout info;
    access_log /dev/stdout;

    gzip on;
    gzip_min_length 10240;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types text/plain text/css text/xml application/json text/javascript application/x-javascript application/xml;
    gzip_disable "MSIE [1-6]\.";

    location / {
        try_files $uri $uri/ =404;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
        expires 5d;
    }

    # deny access to . files, for security
    #
    location ~ /\. {
            log_not_found off;
            deny all;
    }

}
EOF

cat > $(pwd)/index.html <<'EOF'
hello nginx!
EOF

cat > $(pwd)/index.php <<'EOF'
<?php var_export($_SERVER);?>
EOF



docker run -d --name php \
-v $(pwd):/usr/share/nginx/html \
-w /usr/share/nginx/html php:7.4-fpm

docker run -d -it --name nginx \
-v $(pwd):/usr/share/nginx/html \
-v $(pwd)/default.conf:/etc/nginx/conf.d/default.conf \
--link php:php \
-p 19990:80 nginx:1.18.0



curl http://127.0.0.1:19990/index.html && curl http://127.0.0.1:19990/index.php
docker rm -f nginx php

etcd

# upgrade etcd
#docker run --name etcd-tmp -d --rm quay.io/coreos/etcd:v3.4.9 /bin/sh -c "sleep 10s;";
#docker cp etcd-tmp:/usr/local/bin/etcd /usr/local/bin/etcd
#docker cp etcd-tmp:/usr/local/bin/etcdctl /usr/local/bin/etcdctl

curl -sfSL -O https://github.com/etcd-io/etcd/releases/download/v3.4.9/etcd-v3.4.9-linux-amd64.tar.gz
tar -xvf etcd-v3.4.9-linux-amd64.tar.gz


systemctl stop etcd && \
/bin/cp etcd-v3.4.9-linux-amd64/etcd /usr/local/bin/etcd && \
/bin/cp etcd-v3.4.9-linux-amd64/etcdctl /usr/local/bin/etcdctl && \
chown root:root /usr/local/bin/etcd && \
chown root:root /usr/local/bin/etcdctl && \
systemctl start etcd && \
systemctl status etcd -l && \
etcd --version

journalctl -e -x --no-pager --unit etcd |grep -i -E 'err|war'




docker run -dit \
-v $(pwd)/jellyfin/cache:/cache \
-v $(pwd)/jellyfin/config:/config \
-v $(pwd)/jellyfin/media:/media \
-p 8096:8096 --restart=unless-stopped \
--name=jellyfin jellyfin/jellyfin

mysql

docker run -d --name mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
-v $(pwd)/mysql:/var/lib/mysql \
-p 3306:3306 \
mariadb/server:10.4

select @@GLOBAL.sql_mode
STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

docker run -d --name some-mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
-v $(pwd)/mysql5.7:/var/lib/mysql \
-p 3307:3306 \
mysql:5.7.31

select @@GLOBAL.sql_mode
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

docker run -d --name some-mysql2 -e MYSQL_ROOT_PASSWORD=123456 mysql:8.0.21
select @@GLOBAL.sql_mode
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION


docker run -it --rm docker:19.03.12 sh -c "ls -l /usr/local/bin"

nginx

mkdir -p nginx-conf.d


cat default.conf

server {
    listen   80;
    root /usr/share/nginx/html;
    index index.php index.html index.htm;
}

docker run -d \
--name mynginx \
-v $(pwd)/nginx-conf.d:/etc/nginx/conf.d/ \
-p 7100:80 \
nginx:1.16.1

curl http://127.0.0.1:7100


cat /proc/self/cgroup
head -1 /proc/self/cgroup|cut -d/ -f3
containerID=$(awk -F/ '/docker/{print $NF;exit;}' /proc/self/cgroup)
curl -s --unix-socket /var/run/docker.sock http:/v/containers/$containerID/json


/sbin/ip route|awk '/default/ { print $3 }'