Docker notes #1
I am not a devops engineer means that I am not into the deployment things, however, I want to learn about the Docker. Also I want to utilize it in the development setup on our software team.
Therefore, I have started to learn it from the ground. I will publish my notes about it in the process.
General info
Unlike the virtualization, Docker has containerization. Containers share the same kernel of the host.
It's much faster and lightweight compared to virtualization.
Docker has public images you can download and use. Example:
docker run centos
uses the official image centos. If it's not installed in the host, it will download from the docker hub.Docker containers exit automatically after running if there is no running process left.
Commands
docker ps
Shows the running containers
docker ps -a
Shows all containers including the exited ones.
docker rm <container_id_or_name>
Removes the container. Tip: You don't need to write IDS full, write a couple of chars from the beginning.
Example:
➜ ~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b26772f74f32 ubuntu:14.04 "/bin/bash" 3 seconds ago Exited (0) 14 seconds ago xenodochial_hoover
2b8393811355 ubuntu:14.04 "/bin/bash" 6 seconds ago Exited (0) 17 seconds ago determined_agnesi
➜ ~ docker rm 2
2
➜ ~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b26772f74f32 ubuntu:14.04 "/bin/bash" 11 seconds ago Exited (0) 23 seconds ago xenodochial_hoover
docker images
Shows the installed images
docker rmi <image>
Removes the image. If there is a container running based on the image, you need to stop the container first.
docker pull image
Pulls the image from docker hub. It can be also username/imagename
for unofficial images.
docker stop <container>
Stops the running container.
docker run <container> <command>
Starts a container and runs the command.
Ex: docker run ubuntu:14.04 cat /etc/*release*
Note: if you want to run in detached, use -d param.
docker exec <container_id> cat /etc/passwd
Execute commands on running containers.
docker run -it <image>
Creates a container from the image, runs an interactive TTY. (shell)
docker start $(docker ps -a --format "{{.ID}}")
Aktif çalışma dizinimdeki containerları kaldırmak için kullandığım bir komut. Bazen kalabalık bir container listesi olunca böyle minik betikler yazmak/kullanmak hoşuma gidiyor. :)
güzel trick. ✌️
One year old !BEER
_
View or trade
BEER
.Hey @emrebeyler, here is a little bit of
BEER
for you. Enjoy it!