PART-1: Basic docker commands
* Let's suppose you have built an image.
Display list of your docker images:
Output:
As you can see image name is
To run the image:
The above command runs the docker image. The newly created processs by
host, and the second port
Now to see list of your containers use
From here you can see the ID of your container which is equal to
ontainer (login into container):
if you want to connect to the stdout of your container use
*** IF you are attached to a container and press ^c afterward, the container will be stopped.
If you want to stop a container:
It prints out container id
#docker #commands #docker_part1 #basic #container #devops
* Let's suppose you have built an image.
Display list of your docker images:
docker images
Output:
REPOSITORY TAG IMAGE ID CREATED SIZE
py_app latest baa470dc5609 3 weeks ago 591MB
As you can see image name is
py_app
.To run the image:
docker run -it -d -p 8085:8084 py_app
The above command runs the docker image. The newly created processs by
docker run
from your py_app
image is called a container
. -d
runs the image as a daemon and print the container id to your console:$ docker run -it -d -p 8085:8084 py_app
d612ffbd9d560158f1c64997f9a8877243cdf4288c11010298df80b10cfaff5e
-p
exposes the port on your docker file to the port on your host machine. The first port 8085
is the port on yourhost, and the second port
8084
is the port on your docker file.Now to see list of your containers use
docker ps
:docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d612ffbd9d56 py_app "python app.py" 10 minutes ago Up 10 minutes goofy_hopper
From here you can see the ID of your container which is equal to
d612ffbd9d56
. IF you want to have a shell on your container (login into container):
docker exec -it d612ffbd9d56 bash
root@moby:/app#
if you want to connect to the stdout of your container use
attach
, it does not necessary give you a shell:docker attach d612ffbd9d56
*** IF you are attached to a container and press ^c afterward, the container will be stopped.
If you want to stop a container:
$ docker stop d612ffbd9d56
d612ffbd9d56
It prints out container id
d612ffbd9d56
and stop the container. If you enter docker ps
you should not see the container.#docker #commands #docker_part1 #basic #container #devops
One the most useful commands in
In case you want to just delete inside of something and you don't want to go into
Let's give an example. Suppose we have lines like below and we have opened it in vim:
Place the cursor between double quotes somewhere in the
Now let's assume we have a block of code like below:
Go inside of the block of curly braces (`{}`) and put your cursor inside of the block. Now press
You can do the same with every block of code and every character like
#vim #tricks #commands #change #delete #ci #di
vim
is to delete or change inside of a block like {}
or inside of a charater like "SOME THING"
.In case you want to just delete inside of something and you don't want to go into
INSERT
mode just press di
keyboard buttons in order, otherwise press ci
keyboard buttons to go in INSERT
mode and change something.Let's give an example. Suppose we have lines like below and we have opened it in vim:
user_id = "43dd94e5d79ffeb2ffffabd112d5e945"
name = "Alireza"
dob = "SECRET :)"
Place the cursor between double quotes somewhere in the
SECRET :)
and press d
then press c
keys and finally press double quote ("). The vim will search for the surrounding double quotes and will remove everything inside of it. Our output is:user_id = "43dd94e5d79ffeb2ffffabd112d5e945"
name = "Alireza"
dob = ""
Now let's assume we have a block of code like below:
users_data = {
}
Go inside of the block of curly braces (`{}`) and put your cursor inside of the block. Now press
c
on your keyboard then press i
afterward, and at the end press {
on your keyboard. It will delete everything inside of {}
for you and put your vim mode in INSERT
mode. So you would have the following output:users_data = {
}
You can do the same with every block of code and every character like
()
, []
, ''
, etc.ci
stands for Change Insidedi
stands for Delete Inside#vim #tricks #commands #change #delete #ci #di