-
-
Notifications
You must be signed in to change notification settings - Fork 1
HOWTO dev docker_setup
-
How To Install and Use Docker on Ubuntu 18.04, by DigitalOcean
-
How to install Docker On Ubuntu 18.04, by PhoenixNap
-
How to install docker-compose On Ubuntu 20.04 by DigitalOcean
docker-ce is provided by docker.com, docker.io is provided by Debian.
The first installs all the dependencies (possibly creating library duplicates), the second one typically goes the APT way and uses dynamic linking.
Make sure any old version is uninstalled:
$ sudo apt-get remove docker docker-engine docker.ioInstall & enable the service:
$ sudo apt install docker.io
$ sudo systemctl start docker
$ sudo systemctl enable dockerVerify the installation:
$ docker -v
$ sudo service docker status
$ sudo docker infoPrefixing some commands with sudo may force you to use sudo's -E parameter to pass over any environment variable you may be using. For instance, something like DB_DATA=/my_data/folder docker run mongo -d, when using sudo would need to become sudo -E DB_DATA=/my_data/folder docker run mongo -d, which is a minor inconvenience but nevertheless required.
If you want to avoid typing sudo before each command, simply add your user to the docker group.
To do that, create the group if it's missing:
$ sudo groupadd dockerAdd your current user (env variable $USER) to it:
$ sudo usermod -aG docker $USER....Then log-out & re-log in to make the changes effective.
It is also possible to run Docker in "rootless" mode, but this currently has limitations. Check out the official Docker guide on rootless mode and security.
-
docker pull image_name:versioning_tagwill download on localhost from the official public Docker registry the Docker image namedimage_name, associated with the specifiedversioning_tag; for instance,docker pull mongo:4.2.6will download the 4.2.6 version of the MongoDB image. -
docker imagesgives you a list of the existing Docker images on localhost. -
docker psgives you a list of the running containers (ps -ato list also stopped containers). -
docker build .creates a local Docker image from theDockerfilein the current directory. -
docker run --name container_name -d image_nameruns a container in detached mode, (creating it with the specified name), using the Dockerimage_namefactory image; if the-dflag is not present, the container will run in foreground and you will need to press -c to exit. -
docker stop service_name_or_container_idstops a container running in the background or in another process. -
docker start container_idwill restart a previously stopped container. -
docker rm container_name_or_idremoves an existing container. -
docker rmi image_nameremoves an existing Docker image. -
docker exec container_name_or_id context_commandwill executecontext_commandinside the running container, whatever that may be. For exampledocker exec -it mongo bashwill open an interactive bash terminal in a running container named "mongo" (this way, you can connect to the database running inside the container, by executing then themongoclient after the new bash shell opens up).
See the official Docker CLI docs for more information.