tiancheng91 / collection

笔记
https://github.com/tiancheng91/collection/issues
22 stars 1 forks source link

docker #21

Open tiancheng91 opened 5 years ago

tiancheng91 commented 5 years ago

FROM arm64v8/alpine:3.9

RUN echo https://mirrors.cloud.tencent.com/alpine/v3.9/main > /etc/apk/repositories; \ echo https://mirrors.cloud.tencent.com/alpine/v3.9/community >> /etc/apk/repositories

RUN apk --no-cache add py3-lxml py3-curl py3-crypto py3-certifi py3-gevent py3-greenlet py3-mongo py3-redis py3-tornado py3-requests py3-six

tiancheng91 commented 4 years ago

docker container

docker build -t friendlyhello . # Create image using this directory's Dockerfile docker run -p 4000:80 friendlyhello # Run "friendlyhello" mapping port 4000 to 80 docker run -d -p 4000:80 friendlyhello # Same thing, but in detached mode docker container ls # List all running containers docker container ls -a # List all containers, even those not running docker container stop # Gracefully stop the specified container docker container kill # Force shutdown of the specified container docker container rm # Remove specified container from this machine docker container rm $(docker container ls -a -q) # Remove all containers docker image ls -a # List all images on this machine docker image rm # Remove specified image from this machine docker image rm $(docker image ls -a -q) # Remove all images from this machine docker login # Log in this CLI session using your Docker credentials docker tag username/repository:tag # Tag for upload to registry docker push username/repository:tag # Upload tagged image to registry docker run username/repository:tag # Run image from a registry

docker sawrm

docker stack ls # List stacks or apps docker stack deploy -c # Run the specified Compose file docker service ls # List running services associated with an app docker service ps # List tasks associated with an app docker inspect # Inspect task or container docker container ls -q # List container IDs docker stack rm # Tear down an application docker swarm leave --force # Take down a single node swarm from the manager

docker service env

docker-compose -f docker-compose.yml -f docker-compose.prd.yml --env-file ./config/.env.prd up

docker service extend

webapp:
  build: .
  ports:
    - "8000:8000"
  volumes:
    - "/data"
web:
  extends:
    file: common-services.yml
    service: webapp
tiancheng91 commented 4 years ago
docker service create \
  --mode global \
  --replicas 10 \
  --replicas-max-per-node 1 \
  --name redis \
  --update-delay 10s \
  --update-parallelism 2 \
  --publish published=8080,target=80
  --name hosttempl --hostname="{{.Node.Hostname}}-{{.Node.ID}}-{{.Service.Name}}"\
  redis:3.0.6
tiancheng91 commented 3 years ago

--cpus=0.2 // cpu个数(时间片) --cpuset-cpus="1,2,3" // 绑定到核心上 --cpu-shares=512 // 争用时资源比例