Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of practical tips for daily use of docker (recommended)

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Preface

Docker is an open source engine that automatically deploys development applications to containers. It was written by the Docker team and licensed under the Apache 2.0 open source agreement. It provides a simple, lightweight modeling method, makes the development life cycle more efficient and faster, and encourages service-oriented architecture design. The goal of the Docker project is to implement a lightweight operating system virtualization solution. Docker is based on technologies such as Linux container (LXC). Docker is further encapsulated on the basis of LXC, so that users do not need to care about the management of the container, making the operation easier. Users can manipulate Docker containers as easily as a fast and lightweight virtual machine.

Docker may scare you at first, but it is a great tool.

In order to make better use of docker, it is recommended to upgrade to 1.13. Note that the following commands are based on 1.13!

# upgrade instruction (centos7 tested) yum-config-manager-- add-repo https://docs.docker.com/v1.13/engine/installation/linux/repo_files/centos/docker.repo yum makecache fast yum- y remove docker docker-common container-selinux yum- y install docker-engine-1.13.1

Clear the disk space occupied by docker

# clear images that are not dependent and containers that stop running Unused Container Volume and Network (Force Clean-f) docker system prune# Clean undependent Mirror (Force Clean-f) docker image prune# Clean stopped Container (Force Clean-f) docker container prune# Clean unused Network (Force Clean-f) docker network prune# Clean unused Container Volume (Force Clean-f) docker volume prune

Check the docker space occupied by docker

Docker system df

Create a self-starting container

Docker run-restart=always my_image

Create exit self-delete container

Docker run-rm my_image

Container health examination

# specify (timeout command timeout, health-interval check interval) docker run-d-- health-cmd "curl-f http://localhost/123 | | exit 1"-- health-interval=5s-- timeout=3s my_image# Dockerfile specify (timeout command timeout, interval check interval) HEALTHCHECK-- interval=60s-- timeout=10s CMD curl-f http://127.0.0.1/ | | exit 1

Docker swarm cluster related commands

# create cluster docker swarm init-- advertise-addr {local address} # get join cluster command (administrator node) docker swarm join-token manager# get join cluster command (ordinary node) docker swarm join-token worker# display node list docker node ls# display existing service docker service ls# display container docker service ps {service name} # create a service docker service create-- Replicas {number of instances}-name {service name}-p {host port}: {container internal port} my_image {startup instruction} # Delete a service docker service rm {service name} # modify the number of instances docker service scale {service name} = {number of services} # modify the instance using the image docker service update-- image {image name} {service name} # modify the instance Memory limit docker service update-- limit-memory {memory usage} {Service name} # modify instance cpu limit docker service update-- limit-cpu {memory usage} {Service name}

Check the resources occupied by the container

Docker stats

View all mirrors

Docker images

View the container

# View running Container docker ps# View all Container docker ps-a

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report