docker安装常用软件

〇、centos7安装docker

#卸载
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine
#安装依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
#添加软件源信息
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#更新 yum 缓存
yum makecache fast
#安装 Docker-ce
yum -y install docker-ce
#增加目录
mkdir -p /etc/docker/
#配置国内源
vim /etc/docker/daemon.json

daemon.json:

{
  "registry-mirrors" : [
    "http://ovfftd6p.mirror.aliyuncs.com",
    "http://registry.docker-cn.com",
    "http://docker.mirrors.ustc.edu.cn",
    "http://hub-mirror.c.163.com"
  ],
  "insecure-registries" : [
    "registry.docker-cn.com",
    "docker.mirrors.ustc.edu.cn"
  ],
  "debug" : true,
  "experimental" : true
}
#启动docker
systemctl start docker

一、redis

docker run -d --name redis -p 6379:6379 redis --requirepass "1234qwer"

二、portainer

docker run -d -p 9000:9000 --name portainer -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer

三、nginx

docker run -d --name nginx -p 80:80 -v /data/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf nginx

四、jenkins

docker run -d --name jenkins --user root -p 8080:8080 -p 50000:50000 jenkins/jenkins

五、rocketMQ

①启动NameServer
docker run -d -p 9876:9876 --name rmqserver  foxiswho/rocketmq:server-4.7.0
②启动broker
mkdir -p /data/docker/rocketmq-broker/conf
vim /data/docker/rocketmq-broker/conf/broker.conf
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = 宿主机IP
docker run -d -p 10911:10911 -p 10909:10909\
 --name rmqbroker --link rmqserver:namesrv\
 -e "NAMESRV_ADDR=namesrv:9876" -e "JAVA_OPTS=-Duser.home=/opt"\
 -e "JAVA_OPT_EXT=-server -Xms512m -Xmx512m"\
 -v /data/docker/rocketmq-broker/conf:/etc/rocketmq/ \
 foxiswho/rocketmq:broker-4.7.0
②启动rmqconsole
docker run -d --name rmqconsole -p 8181:8080 --link rmqserver:namesrv\
 -e "JAVA_OPTS=-Drocketmq.namesrv.addr=namesrv:9876\
 -Dcom.rocketmq.sendMessageWithVIPChannel=false"\
 -t styletang/rocketmq-console-ng
六、gitlab中文版
docker pull twang2218/gitlab-ce-zh:latest
mkdir -p /data/docker/gitlab/config
mkdir -p /data/docker/gitlab/logs
mkdir -p /data/docker/gitlab/data
docker run --detach --publish 443:443 --publish 8082:80 --publish 23:22 --name gitlab --restart always --volume /data/docker/gitlab/config:/etc/gitlab --volume /data/docker/gitlab/logs:/var/log/gitlab --volume /data/docker/gitlab/data:/var/opt/gitlab twang2218/gitlab-ce-zh
七、ES6+kibana
docker pull elasticsearch:6.8.2
sysctl -w vm.max_map_count=262144
docker run -it --name elasticsearch   -d -p 9200:9200 -p 9300:9300 -p 5601:5601 elasticsearch:6.8.2
docker run -it -d -e ELASTICSEARCH_URL=http://127.0.0.1:9200  --name kibana --network=container:elasticsearch kibana:6.8.2
八、docker registry
docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:latest
九、自定义微服务镜像和创建启动容器

Dockerfile:

#基于哪个镜像
FROM openjdk:8-jdk-alpine
#将本地文件夹挂在到当前容器
VOLUME /tmp
#复制文件到容器
ADD target/demo-0.0.1-SNAPSHOT.jar /app.jar
#声明需要暴露的端口
EXPOSE 8080
#配置容器启动后执行的命令
ENTRYPOINT ["java","-jar","/app.jar"]
#构建镜像
docker build -t grace/demo:0.0.1 .
#不指定容器name和端口,便于同时启动多个相同容器
docker run -d -P grace/demo:0.0.1
#推到docker registry
docker push grace/demo:0.0.1
十、镜像导入导出

导出:

docker save -o XXX.tar 镜像名:版本
或
docker save > XXX.tar 镜像名:版本

导入:

docker load -i XXX.tar
或
docker load < XXX.tar

sudo docker run -d --name wechat --device /dev/snd --ipc="host"
-v /tmp/.X11-unix:/tmp/.X11-unix
-v DISPLAY
-e XMODIFIERS=@im=fcitx
-e QT_IM_MODULE=fcitx
-e GTK_IM_MODULE=fcitx
-e AUDIO_GID=getent group audio | cut -d: -f3
-e GID=id -g
-e UID=id -u
bestwu/wechat

docker run -d --net host --name proxy-client -v /data/docker/proxy-client/conf/config.properties:/usr/local/proxy-java-client-0.1/conf/config.properties -v /data/docker/proxy-client/logs/:/usr/local/proxy-java-client-0.1/logs/ proxy-client

mkdir -p /data/mysql/data /data/mysql/logs /data/mysql/conf
docker run -p 3306:3306 --name mysql -v /data/mysql/conf:/etc/mysql/conf.d -v /data/mysql/logs:/logs -v /data/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password -d mysql:5.7

nacos
docker run --restart=always --env MODE=standalone -v /data/nacos/conf/application.properties:/home/nacos/conf/application.properties -v /data/nacos/logs:/home/nacos/logs/ --name nacos -d -p 8848:8848 nacos/nacos-server

你可能感兴趣的:(docker安装常用软件)