Installing Tools

In GNU/Linux, you can download and install a software by one command (which is difficult to do in Windows). This is achieved by the package manager. Different GNU/Linux distribution has different package manager. In Debian, the package manager is called apt.

You will download and install some tools needed for the PAs from the network mirrors. Before using the network mirrors, you should check whether the container can access the Internet.

Checking network state

By the default network setting of the container will share the same network state with your host. That is, if your host is able to access the Internet, so does the container. To test whether the container is able to access the Internet, you can try to ping a host outside the university LAN:

ping www.baidu.com -c 4

However, you will receive an error message:

ping: icmp open socket: Operation not permitted

This is because ping requires superuser privilege to run inside a container.

Why some operations require superuser privilege?

In a real GNU/Linux, shutting down the system also requires superuser privilege. Can you provide a scene where bad thing will happen if the shutdown operation does not require superuser privilege?

To run ping with superuser privilege, use sudo. Note that this sudo is not the same as the one used in a real GNU/Linux system. If you are careful enough, you will find in the Dockerfile that the sudo command is set as an alias of gosu, which is installed while building the image. Inside a container, we should avoid using the real sudo, since it may cause some problems. We have already hidden the difference between them, and you do not have to worry about the details. For more detail information, please refer to the related Docker Doc.

If you find an operation requires superuser permission, append sodu before that operation. For example,

sudo ping www.baidu.com -c 4

Now you should receive reply packets successfully:

PING www.a.shifen.com (220.181.111.188) 56(84) bytes of data.
64 bytes from 220.181.111.188: icmp_seq=1 ttl=51 time=5.81 ms
64 bytes from 220.181.111.188: icmp_seq=2 ttl=51 time=6.11 ms
64 bytes from 220.181.111.188: icmp_seq=3 ttl=51 time=6.88 ms
64 bytes from 220.181.111.188: icmp_seq=4 ttl=51 time=4.92 ms

--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 4.925/5.932/6.882/0.706 ms

If you get an "unreachable" message, please check whether you can access www.baidu.com in the host system.

Updating APT package information

Now you can tell apt to retrieve software information from the sources:

apt-get update

This command requires root permission, too. And it requires Internet accessing. It costs some time for this command to finish.

Installing tools for PAs

The following tools are necessary for PAs:

apt-get install build-essential    # build-essential packages, include binary utilities, gcc, make, and so on
apt-get install gcc-doc        # GCC document
apt-get install gdb            # GNU debugger
apt-get install git            # reversion control system
apt-get install time        # we use the GNU time program instead of the build-in one in bash

The usage of these tools is explained later.

results matching ""

    No results matching ""