Skip to content

Commit

Permalink
docker cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
zzlion committed Apr 25, 2023
1 parent 20d184f commit 185ac3c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion content.en/posts/20230423.md
@@ -1,7 +1,7 @@
---
title: wsl端口windows访问
description: ""
date: 2023-04-24
date: 2023-04-23
tags:
- 202304
- wsl
Expand Down
67 changes: 67 additions & 0 deletions content.en/posts/20230425.md
@@ -0,0 +1,67 @@
---
title: docker命令行
description: ""
date: 2023-04-25
tags:
- 202304
- docker
categories:
- 202304
menu: main
---

## 重要

1. image是静态文件,container是运行在内存中的进程
1. 容器内程序必须前台运行

## docker build

1. `docker build .` 构建image
1. `docker build -t <image-name>/<repo-name>:<tagname> .`

## docker run

1. `docker run --publish 80:80/tcp <image>` 前台运行
1. `docker run --publish 80:80/tcp --detach <image>`
1. `docker run --publish 80:80/tcp --d <image>`

- -publish/-p
1. 开启host与容器内端口映射
- -e
1. -e FLASK_ENV=production

## docker logs

1. `docker logs --folow <container>`
1. `docker logs --f <container>`

## docker ps

1. `docker ps`查看运行的容器

## docker stop

1. `docker stop <container>` graceful 结束运行的容器

## docker kill

1. `docker kill <container>` crude 结束运行的容器

## docker push

1. `docker push <image name>/<repo-name>:<tagname>`

## docker container

- ls
1. `docker container ls -a`
- rm
1. `docker container rm <hashid>`

## docker image

- ls
1. `docker image ls`
- rm
1. `docker image rm <image-name>` ref的container都移除后才可以删除

1 comment on commit 185ac3c

@vercel
Copy link

@vercel vercel bot commented on 185ac3c Apr 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.