One day, I am working on creating a docker image for a customized ROS package. In the Dockerfile, I wrote the apt-get command
to do the update and install the required ROS packages such as rosbridge-server
and rospy-message-converter
. However, during
the docker build process, I encountered the following errors:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
Step X/X : RUN apt-get update && apt-get install -y ros-noetic-rosbridge-server ros-noetic-rospy-message-converter
---> Running in xxxxxxxxxxxx
Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:3 http://packages.ros.org/ros/ubuntu focal InRelease
Temporary failure resolving 'packages.ros.org'
Err:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Failed to fetch http://packages.ros.org/ros/ubuntu/dists/focal/InRelease Temporary failure resolving 'packages.ros.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
|
I tried to find a solution and I found a good one which is configuring the DNS for our docker. You can configure the DNS in
/etc/docker/daemon.json
file. In my case, since I was using Indihome from Magelang, the closest DNS would be Indihome DNS
in Semarang. So, I configure the dns to 203.130.208.18
.
1
2
3
4
|
#/etc/docker/daemon.json
{
"dns": ["203.130.208.18"]
}
|
Don’t forget to restart the docker service.
1
|
sudo service docker restart
|
Once it has been configured, the build process going smoothly and I can use apt-get command inside the docker.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
Step X/X : RUN apt-get update && apt-get install -y ros-noetic-rosbridge-server ros-noetic-rospy-message-converter
---> Running in xxxxxxxxxxxx
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:3 http://packages.ros.org/ros/ubuntu focal InRelease [4676 B]
Get:4 http://packages.ros.org/ros/ubuntu focal/main amd64 Packages [582 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [1092 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:9 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [30.1 kB]
Get:10 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [543 kB]
Get:11 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [791 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [33.3 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1071 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [590 kB]
Get:18 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1537 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [6310 B]
Get:20 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [2668 B]
Fetched 19.7 MB in 49s (403 kB/s)
Reading package lists...
|
That’s it. Hope it can help you if you have similar issue with Docker internet connection. Thanks for reading!