这是我第二天与docker一起玩,我正在尝试使用docker创建一个简单的Django Web服务器。所以基本上我在目录中创建了Dockerfile
和docker-compose.yml
文件,我将docker-compose.yml
设置为:
version: '3'
services:
web:
build: .
command: python manage.py runserver 0.0.0.0:8080
volumes:
- .:/app
ports:
- "8080:8080"
env_file:
- ./env.dev
我想要实现的是按照我的想法将这些文件推送到docker hub(存储库)中,然后将它们从存储库中提取出来。所以基本上我打开终端并启动以下命令:
docker images
docker tag ID docker_username/repo_name:firsttry
docker push docker_username/repo_name
在推送之后,我可以看到我在中心中有一个存储库,其中包含某种类型的图像历史记录,因此现在我试图将数据提取到本地PC中。 我的命令:
cd some_directory
docker pull dziugasiot/wintekaiot:firsttry
我得到的答复是:
firsttry: Pulling from dziugasiot/wintekaiot
Digest: sha256:477a0bb335f841875d43f0f5717c0416a500989f280112c36b613aa97d82157e
Status: Image is up to date for dziugasiot/wintekaiot:firsttry
docker.io/dziugasiot/wintekaiot:firsttry
目录为空,我在做什么错了?
答案 0 :(得分:2)
您没有做错,但在想错。
Docker push,将图像发送到dockerhub
Docker pull,将您的映像下载到系统中的docker文件夹中,而不是您所在的目录中。您可以使用以下命令查看已提取的映像:docker images
(显示列表)
已下载提取的图像,您可以在运行命令的任何目录中使用它:docker run -it dziugasiot/wintekaiot:firsttry bash
(创建容器)
答案 1 :(得分:1)
为该图像创建容器所需的所有“文件”(层)均已下载,请参见消息“状态:dziugasiot / wintekaiot:firsttry的图像为最新”
Docker使用写时复制机制,因此简而言之:下载映像后,无需再次下载(对于相同版本)。
对于Docker初学者,我不建议在Docker根文件夹中执行任何操作,但要获得完整答案:您可以在Docker根文件夹中找到映像文件(层)。它的位置和格式取决于您的实际配置,但是您可以通过发出"ego.power-tools": {
"buttons":
[
{
"text": "Save & Compile",
"tooltip": "Compile all the .Jack files in the current folder.",
// Running the macro on button click
"action":
{
"type": "command",
"command": "macros.compile_button_click"
}
}
],
"commands": {
// Define a command that runs a script
"compile_folder": {
"script": "compile_folder.js"
}
}
},
"macros": {
// Define a macro command
"compile_button_click": [
"workbench.action.files.saveAll",
"compile_folder"
]
}
命令并寻找Docker Root来查找它。