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

Command sharing commonly used in Docker

2025-03-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article introduces the knowledge of "sharing commands commonly used in Docker". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

View the root user password of the container

Docker logs 2 > & 1 | grep'^ User:'| tail-N1

Because the password of the root user when the docker container starts is randomly assigned. So, in this way, you can get the password of the root user of the redmine container.

View container log

Docker logs-f

View running containers

Docker ps

Docker ps-an is to view all containers, including those that have been stopped.

Delete all containers

Docker rm $(docker ps-a-Q)

Delete a single container docker rm

Stop, start, kill a container

Docker stop docker start docker kill

View all mirrors

Docker images

Delete all mirrors

Docker rmi $(docker images | grep none | awk'{print $3}'| sort-r)

Run a new container and name it, port mapping, and folder mapping. Take redmine image as an example

One container is connected to another

Docker run-I-t-- name sonar- d-link mmysql:db tpires/sonar-server

The sonar container connects to the mmysql container and renames the mmysql container to db. In this way, the sonar container can use the relevant environment variables of db.

Pull the image

Docker pull

Such as docker pull sameersbn/redmine:latest

When you need to migrate an image from one machine to another, you need to save the image and load the image.

Machine a

Docker save busybox-1 > / home/save.tar

Use scp to copy save.tar to machine b, and then:

Docker load < / home/save.tar

Build your own image

Docker build-t

For example, Dockerfile is in the current path: docker build-t xx/gitlab.

If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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