Docker部署

Docker部署

dockerfile

dotnet publish -c Release
#api
FROM mcr.microsoft.com/dotnet/core/aspnet:6

RUN sed -i 's/TLSv1.2/TLSv1/g' /etc/ssl/openssl.cnf \
&& sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf

EXPOSE 80
EXPOSE 443

WORKDIR /app
COPY . .

ENTRYPOINT ["dotnet", "KeyingPlatform.Api.dll"]
#api
docker build -f Dockerfile -t docker-web-sbk:v1 .

docker run --name=jd_sbk -d -p 8080:80 -p 443:443 --restart=always  -v /log/sbk:/app/log docker-web-sbk:latest

docker exec -it jd_sbk bash
#job
FROM mcr.microsoft.com/dotnet/aspnet:6.0

RUN sed -i 's/TLSv1.2/TLSv1/g' /etc/ssl/openssl.cnf \
&& sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf

WORKDIR /app
COPY . .

ENTRYPOINT ["dotnet", "KeyingPlatform.JobWoker.dll"]
#job
docker build -f Dockerfile -t docker-job-sbk .

docker run --name=jd_sbk -d -p 80:80 -p 443:443 --restart=always  -v /log/sbk:/app/log docker-web-sbk:latest

docker exec -it jd_sbk bash

私有镜像

https://blog.csdn.net/yy971733014/article/details/117340342

docker pull registry


docker run -d -p 5000:5000 --name registry --restart always -v /docker/data/registry:/var/lib/registry registry:latest

#访问网址
http://192.168.103.141:5000/v2/_catalog


#修改配置
vi /etc/docker/daemon.json
{"insecure-registries":["192.168.114.134:5000"]}

docker build -f Dockerfile -t hub.key.com:5000/xpt:T0928 .

#永久禁用 SELinux 否则推送会有问题
https://blog.csdn.net/wy7651421/article/details/104091344
#改错还原
https://blog.csdn.net/chrisy521/article/details/123674894

docker push hub.key.com:5000/xpt:T0928

# 
https://zhuanlan.zhihu.com/p/509797691




docker run -p 8280:80 --name registry-ui \
--link registry:registry \
-e REGISTRY_URL="http://registry:5000" \
-e DELETE_IMAGES="true" \
-e REGISTRY_TITLE="Registry" \
-d joxit/docker-registry-ui

dockercompose

version: '3.0'

services:
  docker-web-sbk:
    build:
      #Dockerfile文件的路径
      context: .
      dockerfile: Dockerfile
    image: docker-web-sbk
    container_name: jd_sbk
    #选择端口
    ports:
      - 80:80/tcp
    restart: always
    volumes:
      - /log/sbk:/app/log
docker-compose up -d

ngix

https://www.cnblogs.com/qiqiloved/p/13470064.html

mkdir -p /mnt/nginx/{conf,html,logs}

docker run --name nginx  --restart always -p 80:80 -d nginx 

docker cp nginx:/etc/nginx/nginx.conf /mnt/nginx/
docker cp nginx:/etc/nginx/conf.d/default.conf /mnt/nginx/conf/

docker stop nginx
docker rm nginx

docker run -d --name nginx -p 80:80 -v /mnt/nginx/nginx.conf:/etc/nginx/nginx.conf -v /mnt/nginx/logs:/var/log/nginx -v /mnt/nginx/html:/usr/share/nginx/html -v /mnt/nginx/conf:/etc/nginx/conf.d --privileged=true nginx

portainer

docker pull portainer/portainer-ce

swarm

Swarm initialized: current node (vukdfslvdj1mf9itmotnu8ou7) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-3rx7ft57i4p313n7dtjx80iqem7tqgvnacmuuq5ojw19k7h2dm-40e8i5wik5d48bstyckr2judg 192.168.103.141:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.


docker service create --replicas 1 --name tt alpinr ping docker.com

posted on 2022-10-09 10:52  隨風.NET  阅读(52)  评论(0编辑  收藏  举报

导航