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 | # 1. Run the following command to get the DNS server. |
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 | # In this example, "152.62.40.17" is the argument of "xio-sim-docker.sh". |
How to copy file from containter to host
From here.
1 | # docker cp <containerId>:/file/path/within/container /host/path/target |