CentOS7下安装Docker
准备工作
1 2 3
| yum install -y unzip zip wget vim net-tools lrzsz
|
安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| yum install -y yum-utils yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io
systemctl enable docker
systemctl start docker
docker run hello-world
|
文档: https://docs.docker.com/engine/install/centos/
Docker国内镜像加速
参考文档
安装redis
1 2 3 4 5 6 7
|
docker run -p 6379:6379 --restart=always -d redis:latest redis-server
docker run -it -m 100M --memory-swap -1 -p 6379:6379 --restart=always -d redis:latest redis-server
|
私有镜像库
安装镜像库
下载镜像
运行registry容器
1 2 3 4 5 6 7 8
|
docker run -itd -v /data/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:latest
|
上传镜像
配置镜像服务器
1 2 3 4 5
| [root@node ~]# vim /etc/docker/daemon.json { "registry-mirrors": [ "https://registry.docker-cn.com"], "insecure-registries": [ "镜像服务器IP:5000"] }
|
镜像打标签
1
| docker tag test:latest 镜像服务器IP:5000/test:v1
|
镜像上传
1
| docker push 镜像服务器IP:5000/test:v1
|
查看镜像
1
| curl http://IP:5000/v2/_catalog
|
查看test镜像都有哪些tag
1 2 3 4 5 6 7 8 9 10 11 12 13
| http://镜像服务器IP:5000/v2/busybox/tags/list ···
- MinIO 文件存储(单实例运行) ```bash docker run -itd -p 9000:9000 --restart=always --name minio1 -v /data/minio:/data -e "MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE" -e "MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" minio/minio server /data
docker run -itd -p 9000:9000 --restart=always --name minio1 -v /home/minio/data00:/data00 -v /home/minio/data01:/data01 -v /home/minio/data02:/data02 -v /home/minio/data03:/data03 -v /home/minio/data04:/data04 -v /home/minio/data05:/data05 -v /home/minio/data06:/data06 -v /home/minio/data07:/data07 -v /home/minio/data08:/data08 -v /home/minio/data09:/data09 -e "MINIO_ACCESS_KEY=qwert12345" -e "MINIO_SECRET_KEY=qwert12345" minio/minio server /data00 /data01 /data02 /data03 /data04 /data05 /data06 /data07 /data08 /data09
|
文档:https://docs.min.io/docs/minio-docker-quickstart-guide
1 2 3 4 5 6 7
|
docker run -id --name=ry_mysql -e TZ=Asia/Shanghai -p 3306:3306 --restart=always -e MYSQL_ROOT_PASSWORD=root -v /home/mysqldata:/var/lib/mysql mysql:5.7.38 --lower_case_table_names=1
docker run -it -m 256M --memory-swap -1 -id --name=ry_mysql -e TZ=Asia/Shanghai -p 3306:3306 --restart=always -e MYSQL_ROOT_PASSWORD=root -v /home/mysqldata:/var/lib/mysql mysql:5.7.38 --lower_case_table_names=1
|
1
| docker run -e "ES_JAVA_OPTS=-Xms64m -Xmx251m" --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --restart=always -d elasticsearch:7.2.0
|
docker中的容器时区更改
1
| docker exec -it 容器ID bash
|
1 2 3 4
| ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime echo "Asia/Shanghai" > /etc/timezone
|
1 2
| exit docker restart 容器ID
|
1 2 3 4 5 6
| registry.cn-beijing.aliyuncs.com/qtubiao/openjdk:8-jre-alpine-font
registry.cn-beijing.aliyuncs.com/qtubiao/openjdk:17-jdk-alpine3.14-font
|
1
| docker run -d -p 48081:8081 --privileged=true --name nexus -v /data1/zhongyj/data/nexus-data:/nexus-data --restart=always sonatype/nexus3
|
1 2
| docker compose logs -f -t --tail=10
|
1 2 3 4 5 6
| export http_proxy="http://127.0.0.1:7890" export https_proxy=$http_proxy
alias setproxy="export http_proxy='http://127.0.0.1:7890'; export https_proxy='http://127.0.0.1:7890'; echo '设置代理成功';" alias unsetproxy="unset http_proxy; unset https_proxy; echo '取消代理成功';"
|