First Exploration with Linux

Surf at the sea of command lines.

To start the container, type the following command in the terminal:

docker start oslab-vm

This command will start the container with name oslab-vm, which is created by us. By defualt, oslab-vm will start in detach mode, running the SSH deamon instructed at the end of the Dockerfile. This means we can not interact with it directly. To login the container, we should do the SSH configuration first.

SSH configuration

According to the type of your host operating system, you will perform different configuration.

For GNU/Linux and macOS users

You will use the build-in ssh tool, and do not need to install an extra one. Open a terminal, run

ssh -p 20022 username@127.0.0.1

where username is the user name in Dockerfile. By default, it is oslab. If you are prompted with

Are you sure you want to continue connecting (yes/no)?

enter "yes". Then enter the user password in Dockerfile. If everything is fine, you will login the container via SSH successfully.

For Windows users

Windows has no build-in ssh tool, and you have to download one manually. Download the latest release version of putty.exe here. Run putty.exe, and you will see a dialog is invoked. In the input box labeled with Host Name (or IP address), enter 127.0.0.1, and change the port to 20022. To avoid entering IP address and port every time you login, you can save these information as a session. Leave other settings default, then click Open button. Enter the container user name and password in Dockerfile. If everything is fine, you will login the container via SSH successfully.

First exploration

After login via SSH, you will see the following prompt:

username@hostname:~$

This prompt shows your username, host name, and the current working directory. The username should be the same as you set in the Dockerfile before building the image. The host name is generated randomly by Docker, and it is unimportant for us. The current working directory is ~ now. As you switching to another directory, the prompt will change as well. You are going to finish all the experiments under this environment, so try to make friends with terminal!

Now you can see how much disk space Debian occupies. Type the following command:

df -h

You can see that Debian is quite "slim".

Why Windows is quite "fat"?

Installing a Windows operating system usually requires much more disk space as well as memory. Can you figure out why the Debian operating system can be so "slim"?

To shut down the container, first type exit command to terminate the SSH connection. Then go back to the host terminal, stop the container by:

docker stop oslab-vm

And type exit to exit the host terminal.

Last updated

Was this helpful?