Docker-getting-started
Get started tutorial
啥是docker
- is a runnable instance of an image. You can create, start, stop, move, or delete a container using the DockerAPI or CLI(命令行界面).
- can be run on local machines, virtual machines or deployed to the cloud.
- is portable (can be run on any OS)
- Containers are isolated from each other and run their own software, binaries, and configurations.
1 The example of “Build the app’s container image”
1.1 Get app and Create a Dockerfile
1.1.1 Download the App contents
1.1.2 Create a file named Dockerfile in the same folder as the file package.json with the following contents.
|
|
1.2 Build the container image
|
|
- The
-tflag tags our image. Named imagegeting-started - The
.means that Docker should look for theDockerfilein the current directory
1.3 Start an app container
|
|
-d- run the container in detached mode (in the background)-p 8080:3000- map port 8080 of the host to port 3000 in the containerdocker/getting-started- the image to use
1.4 use use 吧
Add some items
If you take a quick look at the Docker Dashboard, you should see your two containers running now (this tutorial and your freshly launched app container).
2 Update the application
直接改,删了原来的image,再创建
Remove a container using the CLI
-
Get the ID of the container by using the
docker pscommand.1$ docker ps -
Use the
docker stopcommand to stop the container.1 2# Swap out <the-container-id> with the ID from docker ps $ docker stop <the-container-id> -
Once the container has stopped, you can remove it by using the
docker rmcommand.1$ docker rm <the-container-id>
Note
You can stop and remove a container in a single command by adding the “force” flag to the
docker rmcommand. For example:docker rm -f <the-container-id>
3 Push the image
|
|
记录下文档的反人类缩写
来自Sample application | Docker Documentation
- MVP (minimum viable product 最小可行产品)
- CLI(command-line interface命令行界面)
- hub (是吧)
安装问题
-
win10 已开启hyper-v所有服务
打开报错:
System.InvalidOperationExceptionshellFailed to set version to docker-desktop: exit code: -1windows解决:
临时方案:cmd/shell下执行:
netsh winsock reset重启docker
永久方案:在网站消失的时间里,用上了win10企业版,完美运行。