Gangmax Blog

自由之思想,独立之精神

Second Docker Notes

| Comments

Here is some notes about Docker I learned today.

How to solve the “Failed to fetch archive.ubuntu.com” problem

This problem happens when I create a Dockerfile based on the base “Ubuntu” image and want to run “apt-get update && apt-get install -y something” on it. When executing the “apt-get update” step of during Docker building process, it always reports error like “Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease” and so on.

Google and find posts like here and here. But the problem is still there. The final solution comes from here. The key is that, besides enabling the DNS arguments of Docker, I need to use the specific DNS server of my environment instead of the default Google DNS server. Here is the steps.

1
2
3
4
5
6
7
8
# 1. Run the following command to get the DNS server.
nm-tool

# 2. Enable Docker DNS arguments in "/etc/default/docker" file:
DOCKER_OPTS="--dns 8.8.8.8 --dns 10.30.48.37"

# 3. Restart the Docker service.
sudo service docker restart

Done.

How to attach to a running container with bash

From here.

Run the following command:

1
docker exec -it <container-id> bash

How to pass arguments to command when starting a container instance

From here.

For an exampleRun the following commands:

1
2
# In this example, "152.62.40.17" is the argument of "xio-sim-docker.sh".
docker run --name xiosim -p 4430:4430 -p 8020:8020 -d mine/xiosim xio-sim-docker.sh 152.62.40.17

How to copy file from containter to host

From here.

1
# docker cp <containerId>:/file/path/within/container /host/path/target

Comments