Deepin UOS openEuler 安装 Docker 常用服务搭建
Deepin UOS 在线安装 Docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
Ubuntu 在线 安装 Docker
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
开启docker 远程访问API
sudo vim /lib/systemd/system/docker.service
将 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
sudo systemctl daemon-reload
sudo systemctl restart docker
curl http://ip:2375/version
安装Docker管理器 Portainer
sudo docker search portainer
sudo docker run -d -p 9999:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name portainer-test portainer/portainer
sudo docker run -d -p 9999:9000 --restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
--name portainer-test portainer/portainer-ce
sudo docker ps
docker 安装 nginx
sudo docker images
sudo docker search nginx
sudo docker pull nginx
sudo docker run --name nginx-test -d -p 80:80 nginx
sudo docker ps
sudo docker stop nginx-test
sudo docker ps -a
sudo docker start nginx-test
sudo docker ps
sudo docker stop nginx-test
sudo docker rm nginx-test
sudo docker ps -a
sudo docker images
sudo docker rmi nginx
sudo docker exec -it nginx-test /bin/bash
exit
mkdir -p /home/lhz/nginx/html /home/lhz/nginx/conf.d
sudo docker cp nginx-test:/usr/share/nginx/html /home/lhz/nginx
sudo docker cp nginx-test:/etc/nginx/conf.d/default.conf /home/lhz/nginx/conf.d
sudo docker cp nginx-test:/etc/nginx/nginx.conf /home/lhz/nginx
sudo docker stop nginx-test
sudo docker rm nginx-test
sudo docker ps -a
sudo docker run -d -p 80:80 \
-v /home/lhz/nginx/html:/usr/share/nginx/html \
-v /home/lhz/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf \
-v /home/lhz/nginx/nginx.conf:/etc/nginx/nginx.conf \
--name nginx-test --restart=always nginx
docker 安装 mysql
mkdir -p /home/lhz/docker/mysql/{conf,data}
sudo docker search mysql
sudo docker pull mysql
sudo docker run --restart=always -p 3306:3306 -p 33060:33060 \
-v /home/lhz/docker/mysql/data:/var/lib/mysql \
--name mysql-test -e MYSQL_ROOT_PASSWORD=123456 -d mysql
docker 安装 redis
mkdir -p /home/lhz/docker/redis/{conf,data}
cd /home/lhz/docker/redis/conf
wget https://raw.githubusercontent.com/antirez/redis/7.0/redis.conf
sudo docker run -d -p 6379:6379 \
-v /home/lhz/docker/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf \
-v /home/lhz/docker/redis/data:/data \
--name myredis redis redis-server \
/usr/local/etc/redis/redis.conf
sudo docker run --restart=always --name redis-6379 \
-v /home/lhz/docker/redis/data:/data -p 6379:6379 \
-d redis --requirepass 123456
方式一
sudo docker run -itd --name redis-6379 -p 6379:6379 redis --requirepass 123456
sudo docker run --restart=always --name redis-6379 -p 6379:6379 -d redis --requirepass 123456
--name (启动容器的名称)
-p 映射端口:redis启动端口 redis
--requirepass 启动密码
方法二:为现有的redis创建密码或修改密码的方法:
docker exec -it 容器ID bash
cd /usr/local/bin
redis-cli
config get requirepass
config set requirepass 密码
docker 安装 mongodb
mkdir -p /home/lhz/docker/mongodb/db
sudo docker search mongo
sudo docker pull mongo
sudo docker run --name mongodb -p 27017:27017 \
-v /home/lhz/docker/mongodb/db:/data/db \
--restart=always -d mongo:latest
docker 安装 蚂蚁笔记
sudo docker volume create leanote_data
sudo docker pull axboy/leanote
sudo docker run -d --restart=always --name leanote \
-v `pwd`/db:/data/db -v `pwd`/conf/:/data/leanote/conf \
-p 2022:9000 axboy/leanote
openEuler 在线安装 Docker
yum -y update
yum -y install tar vim net-tools zip unzip
yum -y install docker
docker安装minio
1、查看minio的docker版本
使用docker命令查看minio的版本
sudo docker search minio
2、拉取镜像
sudo docker pull minio/minio
3、创建目录:一个用来存放配置,一个用来存储上传文件的目录
sudo mkdir -p /data/minio/config
sudo mkdir -p /data/minio/data
4、运行容器
sudo docker run -p 9000:9000 -p 9090:9090 \
--net=host \
--name minio-test \
-d --restart=always \
-e "MINIO_ACCESS_KEY=minioadmin" \
-e "MINIO_SECRET_KEY=minioadmin" \
-v /data/minio/data:/data \
-v /data/minio/config:/root/.minio \
minio/minio server \
/data --console-address ":9090" -address ":9000"
这里的9090端口指的是minio的客户端端口。虽然设置9090,但是我们在访问9000的时候,他会自动跳到9090。
MINIO_ACCESS_KEY :账号
MINIO_SECRET_KEY :密码
5、防火墙放行端口
firewall-cmd --zone=public --add-port=9000/tcp --add-port=9090/tcp --permanent
firewall-cmd --reload
6、访问查看
http://IP:9090
springboot docker
vim /lib/systemd/system/docker.service
将 ExecStart=/usr/bin/dockerd $OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$INSECURE_REGISTRY
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
systemctl daemon-reload
systemctl restart docker
firewall-cmd --zone=public --add-port=2375/tcp --permanent
firewall-cmd --reload
curl http://ip:2375/version
curl http://ip:2375/images/json
dockerfile
FROM openjdk:17
MAINTAINER 李昊哲<646269678@qq.com>
EXPOSE 6633
ADD target/hellodocker.jar /app.jar
ENTRYPOINT ["java","-jar","/app.jar"]