ObjectiveInstall the latest Docker release on Ubuntu 18.04
DistributionsUbuntu 18.04 Bionic Beaver
RequirementsA working install of Ubuntu 18.04 with root privileges
- # - requires given linux commands to be executed with root privileges either directly as a root user or by use of
- $ - requires given linux commands to be executed as a regular non-privileged user
IntroductionDocker has revolutionized how web applications are hosted and servers are run. Docker containers allow server administrators to compartmentalize their applications like virtual machines, but containers are much lighter weight, are easier to manager, and add less overhead. Installing Docker on Ubuntu is very simple. Because Ubuntu is a popular choice for the cloud, the entire process has been streamlined to a science.
Install Docker from Ubuntu RepositoryInstallation from the standard Ubuntu repository consists of a single
aptcommand. It may yield stable but lower docker version number:
$ sudo apt install docker.ioThe following linux commands will start Docker and ensure that starts after the reboot:
$ sudo systemctl start docker $ sudo systemctl enable dockerAll done.
$ docker --version Docker version 17.03.2-ce, build f5ec1e2
BLUE SKY STUDIOS are looking for Linux Administrator to maintain and support the Studio's 450+ production Linux workstations, including daily interactions with the Studio’s digital animation artists.
LOCATION: Greenwich, Connecticut, USA
Install Docker from the Official Docker Repository
Install the DependenciesDocker has its own repositories. Before you can install it from those repos, you need to install the prerequisite dependencies. Update your system, and grab them with Apt.
$ sudo apt update $ sudo apt install apt-transport-https ca-certificates curl software-properties-common
Add The Docker RepositoryCreate a new file for the Docker repository at
/etc/apt/sources.list.d/docker.list. In that file, place one of the following lines choosing either stable, nightly or edge builds:
STABLE (NOT YET AVAILABLE!), please check availabilty before using: deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable EDGE: deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic edge NIGHTLY: deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic nightlyNext, you need to add Docker's GPG key.
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -Once, that's imported, update Apt again.
$ sudo apt update
Install Docker CEYou can simply install the Docker CE package.
$ sudo apt install docker-ceDone. Check for docker version:
$ docker --version Docker version 18.03.0-ce, build 0520e24
Add A ContainerThere's more than one way to add a Docker container. If you're familiar with Docker, this isn't for you. However, if you've decided to give Docker a try for the first time, the easiest way to get started is to use any of the excellent existing Docker images available online. Docker is configured to pull them automatically for you when you request them by with the name of the developer and the repository.
$ sudo docker run username:repositoryIn the case of officially supported images, you don't need to specify a username. They do tend to come with more options, though. You might want to specify tags for them. That's done with a colon after the repository name.
$ sudo docker run wordpress:php-7.2-fpm-alpineYou can also specify the port that the container listens on. By default, most containers are configured to listen on 80 internally. You can make Docker listen on a different port and forward that to the container's 80.
$ sudo docker run 9000:80 wordpressThat container will listen on the server's port 9000 and forward the traffic to the container's port 80. This makes it easier to run multiple web services on the same server.
Managing ContainersManaging containers is fairly straightforward too. You can probably already guess that starting up a container is the same as adding a new one. That's the
runcommand. In this case, the
-dflag detaches the container, so it's not taking up your terminal.
$ sudo docker run -d wordpressSince you can have multiples of the same container running, almost everything else here uses the hashes that Docker automatically assigns to running containers. To list out all the containers running on your system, use the
$ sudo docker container lsIf you want to stop a container, use
stopfollowed by the hash of that container.
$ sudo docker container stop HASHRemoving a container is easy too. Use
$ sudo docker container rm HASH