Robot Operating System Cookbook
上QQ阅读APP看书,第一时间看更新

Adding the Docker repository to APT sources

For Ubuntu 16.04, add the following:

$ echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list

For Ubuntu 18.04, add the following:

$ echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list 

Updating the package database with the Docker packages from the newly added repository is done as follows:

$ sudo apt-get update

Make sure that we are about to install from the Docker repository instead of the default Ubuntu repository:

$ apt-cache policy docker-engine

Notice that docker-engine is not installed yet; to install docker-engine, use the following command:

$ sudo apt-get install -y docker-engine

Check whether Docker is started or not:

$ sudo systemctl status docker

To start the Docker service, use the following command:

$ sudo service docker start
$ docker

We can search for images available on Docker Hub by using the docker command with the search subcommand:

$ sudo docker search Ubuntu

To run the Docker container, use the following command:

$ sudo docker run -it hello-world