Skip to content

Commit

Permalink
Manipulating Containers with the Docker Client
Browse files Browse the repository at this point in the history
  • Loading branch information
agungTuanany committed Jul 11, 2019
1 parent 4f9def6 commit d038df3
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 1 deletion.
141 changes: 140 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,147 @@ for example a NODEJS, NGINX, or REDIS etc
![what-is-image-1.png](./imgs/what-is-image-1.png)
# What is a Container in Docker ?

Is a instance of an Image to Runs a program.
Is a instance of an Image to runs a program.

It's a program with his own isolated set of hardware resources, it has own set
of memory, it has own space of networking technology, it has own spcae of
hard-drive.

# 001. Docker Run in Detail

![create-and-run-container-1.png](./imgs/create-and-run-container-1.png)

eg:
~~~
docker run hello-world
~~~

# 002. Overriding Default Commands

![overriding-default-command-1.png](./imgs/overriding-default-command-1.png)

eg:
~~~
docker run busybox echo hello world!
~~~

# 003. Listing Running Containers

![listing-running-containers-1.png](./imgs/listing-running-containers-1.png)

eg:
~~~
docker ps
#or
docker ps --all
~~~

# 004. Container Lifecycle

![container-lifecycle-1.png](./imgs/container-lifecycle-1.png)

![container-lifecycle-2.png](./imgs/container-lifecycle-2.png)

eg:
~~~
# create a container
docker create redis
# start a container
docker start 4b263884282
~~~

# 005. Restarting Stopped Container

eg:
~~~
docker start -a 4b263884282
~~~

# 006. Removing Stopped Containers

eg:
~~~
docker system prune
~~~

# 007. Retrieving log Outputs

![retrieving-log-outputs-1.png](./imgs/retrieving-log-outputs-1.png)

eg:
~~~
docker log 4b263884282
~~~

# 008. Stopping Containers

stop command use to take more time for shutdown the container.

kill command use to shutdown the container immediately.

![stopping-containers-1.png](./imgs/stopping-containers-1.png)

# 009. Multi-command Containers

we have two separate containers. we want to include redis-cli container into
redis-server container to run together

![multi-command-containers.gif](./imgs/multi-command-containers.gif)

# 010. Executing Command in Running Containers

![executing-command-in-running-containers-1.png](./imgs/executing-command-in-running-containers-1.png)

eg:
~~~
docker exec -it 4b263884282 redis-cli
~~~

# 011. The Purpose of the IT flag

When you running docker on your computer or machine every single container you
are running is running inside a virtual machine running Linux.

![the-purpose-of-the-it-flag.gif](./imgs/the-purpose-of-the-it-flag.gif)

The IT flag is two separate flag

~~~
-it
# or
-i -t
-i, --interactive Keep STDIN open even if not attached
-t, --tty Allocate a pseudo-TTY | make sure all the text nicely format | auto-complete
~~~

# 012. Getting a Command Prompt in a Container

You will not want to execute without having execute same command.

"sh" is a command processor or a shell its allow to type command in and will be
execute inside the container.

![getting-a-command-prompt-in-a-container-1.png](./imgs/getting-a-command-prompt-in-a-container-1.png)

eg:
~~~
docker exec -it 4b263884282 sh
~~~

# 013. Starting with a Shell

![starting-with-a-shell.gif](./imgs/starting-with-a-shell.gif)

# 014. Container Isolation

The containers do not automatically share their files system

![container-isolation.gif](./imgs/container-isolation.gif)
Binary file added imgs/container-isolation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/container-lifecycle-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/container-lifecycle-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/create-and-run-container-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/listing-running-containers-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/multi-command-containers.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/overriding-default-command-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/retrieving-log-outputs-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/starting-with-a-shell.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/stopping-containers-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/the-purpose-of-the-it-flag.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d038df3

Please sign in to comment.