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

Frequently asked questions about docker

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

Share

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

I. FAQ

1. When the mirrored container is running, if no ip an or ifconfig command is provided, use the following two ways to view the container ip:

1) switch to a container: docker attach xxxx (such as docker attach nginx); then cat / etc/hosts

2) execute the command directly in the host: docker inspect xxxx (such as docker inspect nginx)

A json string is echoed, which contains the container ip of the query.

two。 Error launching Container Times: / bin/bash not found

You can start the container without specifying the interpreter / bin/bash, that is:

Docker run-it-d-- name ng nginx:latest

Instead of using the following command

Docker run-it-d-name ng nginx:latest / bin/bash

3. Cannot attach to the container, that is, the docker attach does not respond

You can use the following command when the container is already running (note that the docker container is already running at a certain time):

Docker exec-it CONTAINER ID / bin/bash or docker exec-it NAME / bin/bash

CONTAINER ID and NAME represent the container ID and container name that have been run; but in this way, every time a command is executed, a new process is started in the docker container

After switching to the container in this way, if you exit through exit,ctrl+C,ctrl+D, the container will not stop running, so this is a safer way to prevent the container from being stopped by mistake.

4. Pull image from the official mirror station of docker hub, the running container is missing command

I pulled the nginx image from the docker official website. After running it, I went into the container and found that there was no wget command. Then I installed the wget command as a matter of course:

Apt-get-y install wget

But the following errors will be reported:

This is due to the fact that all the software lists (i.e. / erc/apt/sources.list) in the software source are not updated in the container in which the original image is running. After executing the following command, you can install it.

Apt-get update

If the company does not support external network links and cannot update the software source, you can search for debian on the company's internal mirror station, and then use the instructions to manually replace the contents of the / erc/apt/sources.list file.

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