Docker is a container virtualization environment that can establish development or runtime environments without modifying the base operating system environment. It has the ability to deploy container instances that provide virtualization using the host kernel, which makes it faster and lighter than full hardware virtualization. Versions
Containers that produce Kernel Panic will induce Kernel Panic in the host’s operating system.
To install we will use the snap. Just remembering that the snap is available for several distributions, such as: Arch, Gentoo, Linux Mint and others. The cool thing about it is that we will avoid problems with Docker versions.
sudo snap install docker
- Installs Dockerps -A | grep docker
- Check if the daemon is already runningsudo docker run hello-world
- Running your first containerThe output will be something like:
cat /etc/group | cut -d: -f1
(to display groups beside: cat /etc/group | cut -d: -f1 | tr '\ n' '' && echo
), if among the groups listed is docker, then that group exists, if you want to run a command that tells you whether or not the group exists, network the command: [[ $(grep 'docker' /etc/group) ]] && echo 'There is the docker group' || echo 'There is no docker group'
sudo groupadd docker
.sudo usermod -aG docker $USER
(or sudo gpasswd -a $USER docker
) and make sure you are now in the group with the groups $USER
command.If you want to remove the user from the group, run:
sudo gpasswd -d $ USER docker
sudo docker run hello-world
, if it runs it is all right.
For this example we will use a Shell Script application: ZZ functions
First, download the container image to your machine:
If you aren’t part of the docker group as mentioned above, use
sudo
for all the following steps.
The output will be something like:
List the images that are already on your machine:
Now just run the container and inform which function you want to use, along with its parameters, example: docker run --rm funcoeszz/zz maiusculas is working
Output:
Search for a container: docker search nginx
Commands for information: docker info
and others, see: docker --help
or docker
only
The docker run command takes the Docker image as a model and produces a container from it.
docker images
or docker image ls
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -a -q)
or docker rmi ID_IMAGE
mkdir myshell && cd myshell
vim Dockerfile
Create shell script file: vim myshell.sh
Or this case for example server, to play for background
chmod +x myshell.sh
docker build --tag=myshell
.
docker image ls
docker run myshell
Container ID:
docker container ls
[Create Repository +], style to create a repository on GitHub: name, description, public..create
docker login
, enter your username [ENTER] and then your password [ENTER]docker tag myshell terminalroot/myshell:v1
or without tag: docker tag myshell terminalroot/myshell
docker push terminalroot/myshell: v1
or if you did not enter a tag: docker push terminalroot/myshell
If you want to test it, just remove all the images and containers and then pull it out at the beginning and see if it’s really working.
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker images
docker rmi IMAGE_ID [nImage_ID ...]
Listing the snaps and removing the snap:
More information: snap.
See all the tips worked in the video below. Remembering that the tutorial is in Portuguese, but you can use the subtitles
The video has English subtitles native to the video itself and with the correct translation. To enable, use the settings in the footer of the video itself, according to the images shown here below.
CLICK ON IMAGES TO VIEW INTO LARGER RESOLUTION.