Skip to content

Commit

Permalink
vault backup: 2024-06-15 19:36:49
Browse files Browse the repository at this point in the history
Affected files:
content/.obsidian/plugins/recent-files-obsidian/data.json
content/.obsidian/workspace.json
content/attachments/docker-container-lifecycle.png
content/docker/Docker CLI Commands.md
content/docker/Docker Container Lifecycle.md
content/docker/Docker Container.md
content/docker/cli-commands/docker run, create, start.md
content/docker/cli-commands/docker stop, kill.md
  • Loading branch information
windsuzu committed Jun 15, 2024
1 parent 819135b commit cb8c098
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 65 deletions.
40 changes: 20 additions & 20 deletions content/.obsidian/plugins/recent-files-obsidian/data.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
{
"recentFiles": [
{
"basename": "Docker Container Lifecycle",
"path": "docker/Docker Container Lifecycle.md"
"basename": "docker stop, kill",
"path": "docker/cli-commands/docker stop, kill.md"
},
{
"basename": "Docker CLI Commands",
"path": "docker/Docker CLI Commands.md"
"basename": "docker run, create, start",
"path": "docker/cli-commands/docker run, create, start.md"
},
{
"basename": "Docker Container Lifecycle",
"path": "docker/Docker Container Lifecycle.md"
},
{
"basename": "Docker Container",
"path": "docker/Docker Container.md"
},
{
"basename": "Docker Image",
"path": "docker/Docker Image.md"
"basename": "Docker CLI Commands",
"path": "docker/Docker CLI Commands.md"
},
{
"basename": "Docker",
"path": "docker/Docker.md"
},
{
"basename": "Docker IT flags",
"path": "docker/Docker IT flags.md"
},
{
"basename": "Docker",
"path": "docker/Docker.md"
"basename": "docker-container-lifecycle",
"path": "attachments/docker-container-lifecycle.png"
},
{
"basename": "Docker Image",
"path": "docker/Docker Image.md"
},
{
"basename": "Install Docker on Windows WSL 2",
Expand Down Expand Up @@ -187,18 +199,6 @@
{
"basename": "PostgreSQL",
"path": "postgresql/PostgreSQL.md"
},
{
"basename": "PostgreSQL Join",
"path": "postgresql/PostgreSQL Join.md"
},
{
"basename": "PostgreSQL Update",
"path": "postgresql/PostgreSQL Update.md"
},
{
"basename": "PostgreSQL Delete",
"path": "postgresql/PostgreSQL Delete.md"
}
],
"omittedPaths": [],
Expand Down
30 changes: 15 additions & 15 deletions content/.obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"state": {
"type": "markdown",
"state": {
"file": "docker/Docker CLI Commands.md",
"file": "docker/cli-commands/docker stop, kill.md",
"mode": "source",
"source": false
}
Expand All @@ -31,8 +31,7 @@
}
}
}
],
"currentTab": 1
]
}
],
"direction": "vertical"
Expand Down Expand Up @@ -115,7 +114,7 @@
"state": {
"type": "localgraph",
"state": {
"file": "docker/Docker Container Lifecycle.md",
"file": "docker/cli-commands/docker stop, kill.md",
"options": {
"collapse-filter": true,
"search": "",
Expand Down Expand Up @@ -165,7 +164,7 @@
"state": {
"type": "outline",
"state": {
"file": "docker/Docker Container Lifecycle.md"
"file": "docker/cli-commands/docker stop, kill.md"
}
}
},
Expand Down Expand Up @@ -206,7 +205,7 @@
"state": {
"type": "file-properties",
"state": {
"file": "docker/Docker Container Lifecycle.md"
"file": "docker/cli-commands/docker stop, kill.md"
}
}
}
Expand All @@ -223,7 +222,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "docker/Docker Container Lifecycle.md",
"file": "docker/cli-commands/docker stop, kill.md",
"linksCollapsed": false,
"unlinkedCollapsed": false
}
Expand All @@ -242,7 +241,7 @@
"state": {
"type": "backlink",
"state": {
"file": "docker/Docker Container Lifecycle.md",
"file": "docker/cli-commands/docker stop, kill.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
Expand Down Expand Up @@ -272,15 +271,18 @@
"cmdr:Obsidian Git: Create backup": false
}
},
"active": "720ac84f203cc18f",
"active": "94dafe9c731fce38",
"lastOpenFiles": [
"docker/Docker CLI Commands.md",
"docker/cli-commands/docker run, create, start.md",
"docker/Docker Container Lifecycle.md",
"docker/cli-commands",
"docker/cli-commands/docker stop, kill.md",
"docker/Docker Container.md",
"docker/Docker Image.md",
"docker/Docker IT flags.md",
"docker/Docker CLI Commands.md",
"docker/Docker.md",
"docker/Docker IT flags.md",
"attachments/docker-container-lifecycle.png",
"docker/cli-commands",
"docker/Docker Image.md",
"docker/Install Docker on Windows WSL 2.md",
"attachments/docker-image.png",
"attachments/docker-container.png",
Expand Down Expand Up @@ -312,13 +314,11 @@
"mocs/JavaScript MOC.md",
"javascript/Pattern Matching (ts-pattern).md",
"javascript/Imperative and Declarative Programming.md",
"react/Controlled Components.md",
"attachments/event-capturing-and-bubbling.png",
"attachments/Pasted image 20240524152334.png",
"prettier",
"postgresql",
"prisma",
"attachments/avatar-jay.jpeg",
"Untitled.canvas"
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 1 addition & 25 deletions content/docker/Docker CLI Commands.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,11 @@
---
draft: false
date: 2024-06-15 15:41
date: 2024-06-15 19:00
tags:
- docker
---



## run

The `run` command from the CLI asks the [[Docker]] server to "create" and "start" a container based on the given [[docker image|image]]. If the image is not found on the local machine, server will retrieve it from the [[Docker]] Hub first.

```bash
docker run [options] image_name [command]
```

>[!example]
> The following example pulls the `busybox` image from the [[Docker]] Hub, then creates and starts a container with it. It also specifies a shell to be started inside the container and the `-i` and `-t` [[Docker IT flags|flags]] to interact directly with the shell in the container.
>
>```bash
>docker run -it busybox sh
>```
>
>PS. `busybox` is a tiny (<5Mb) image that combines many common UNIX utilities into a single executable for crafting space-efficient distributions.
## create
## start
## ps
## exec
## stop and kill
Expand Down
13 changes: 10 additions & 3 deletions content/docker/Docker Container Lifecycle.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
---
draft: false
date: 2024-06-15 16:04
date: 2024-06-15 19:06
tags:
- docker
---

When a Docker container is created with `docker create`, it can be started using `docker start` multiple times (you can also use the `docker run` command to create and start a container simultaneously). The container may run and finish immediately or run for an extended duration, depending on the processes it executes. Once a container has been started and stopped, you can start it again using `docker start` as long as it hasn't been removed.
![[docker-container-lifecycle.png]]
> Source: [Docker Container Lifecycle Management](https://k21academy.com/docker-kubernetes/docker-container-lifecycle-management/)
When a [[Docker]] container is created with `docker create`, it can be started using `docker start` multiple times (you can also use the `docker run` command to create and start a container simultaneously). The container may run and finish immediately or run for an extended duration, depending on the processes it executes.

>[!seealso]
>- [[docker run, create, start]]
When the container is running, you can either stop it using `docker stop`, kill it using `docker kill`, or run additional commands inside the container's environment using `docker exec`, which is a way to interact with the container while it's running.

When container is running, you can stop or kill it. When container is stopped, you can start it again with start or exec command, you can also remove the container from the memory in the local machine using container prune command.
>[!seealso]
>- [[docker stop, kill]]
Once a container has completed its processes and stopped, you can restart it with `docker start`, as long as it hasn't been removed. If you want to remove the container from your machine, you can use `docker container prune` to remove all non-running containers.


> [!info] References
Expand Down
4 changes: 2 additions & 2 deletions content/docker/Docker Container.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
draft: false
date: 2024-06-12 18:19
date: 2024-06-15 19:05
tags:
- docker
---

![[docker-container.png]]

A [[Docker]] container is a process or a set of processes with isolated resources that are logically (not physically) allocated from the hard drive by the kernel using `namespacing` and `cgroups`.
A [[Docker]] container is a process or a set of processes with isolated resources that are logically (not physically) allocated from the hard drive by the kernel using `namespacing` and `cgroups`. Each container has its own lifecycle, see [[Docker Container Lifecycle]] for more information.

- `namespacing` is an OS feature that segments hardware resources for specific processes. For example, creating separate segments on the hard drive for Python 2 and Python 3, and directing system calls to the appropriate segment based on which application is making the call.
- `cgroups` (Control Groups) limit the amount of resources (CPU, memory, network bandwidth) a process can use.
Expand Down
63 changes: 63 additions & 0 deletions content/docker/cli-commands/docker run, create, start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
draft: false
date: 2024-06-15 19:04
tags:
- docker
---

These commands are strongly associated with the [[Docker Container Lifecycle]].
## docker run

The `docker run` command asks the [[Docker]] server to "create" and "start" a container based on the given [[docker image|image]]. If the image is not found on the local machine, server will retrieve it from the [[Docker]] Hub first.

```bash
docker run [options] image_name [command]
```

>[!example]
> The following example pulls the `busybox` image from the [[Docker]] Hub, then creates and starts a container with it. It also specifies a shell to be started inside the container and the `-i` and `-t` [[Docker IT flags|flags]] to interact directly with the shell in the container.
>
>```bash
>docker run -it busybox sh
>```
>
>PS. `busybox` is a tiny (<5Mb) image that combines many common UNIX utilities into a single executable for crafting space-efficient distributions.
## docker create
The `docker create` command takes an [[docker image|image]] and creates a new [[docker container|container]] without running it. It then prints the `container_id` for further operations. You can specify a **startup command** for this container at the time of creation, which will be executed each time the container is started.
```bash
docker create [options] image_name [command]
```
>[!example]
> The following example creates a new container from the `busybox` image and assigns a startup command of `echo hello`.
>
>```bash
>docker create busybox echo hello
># 610ea68044541a3b4e2bac5ca889b6978e1fa529dd5c96199aeeb11b9b9b5765
>```
## docker start
The `docker start` simply starts the [[docker container|container]] we created with `docker create`, or restarts the [[docker container|container]] that was already finished and stopped.
```
docker start [options] container_id
```
>[!example]
>The following example starts the `busybox` container with the command `echo hello`. We also append an `-a` flag to display the output of the container.
>```bash
>docker start -a 610ea68044541a3b4e2bac5ca889b6978e1fa529dd5c96199aeeb11b9b9b5765
># hello
>```
> [!info] References
> - [Docker and Kubernetes: The Complete Guide](https://www.udemy.com/course/docker-and-kubernetes-the-complete-guide)
> - [docker container create | Docker Docs](https://docs.docker.com/reference/cli/docker/container/create/)
> - [docker container start | Docker Docs](https://docs.docker.com/reference/cli/docker/container/start/)
> - [docker run | Docker Docs](https://docs.docker.com/reference/cli/docker/container/run/)
> - [busybox - Official Image | Docker Hub](https://hub.docker.com/_/busybox)
23 changes: 23 additions & 0 deletions content/docker/cli-commands/docker stop, kill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
draft: false
date: 2024-06-15 19:04
tags:
- docker
---

These commands are strongly associated with the [[Docker Container Lifecycle]].

## docker stop





## docker kill



> [!info] References
> - [Docker and Kubernetes: The Complete Guide](https://www.udemy.com/course/docker-and-kubernetes-the-complete-guide)
> - [docker container stop | Docker Docs](https://docs.docker.com/reference/cli/docker/container/stop/)
> - [docker container kill | Docker Docs](https://docs.docker.com/reference/cli/docker/container/kill/)

0 comments on commit cb8c098

Please sign in to comment.