简体   繁体   English

无法看到Docker容器中的内容

[英]Unable to see the contents in the docker container

I am newbie to docker and trying to explore the features of docker. 我是Docker的新手,正在尝试探索Docker的功能。 I created a container and stored some data on it and pushed it onto my docker account. 我创建了一个容器并在其中存储了一些数据,并将其推送到我的Docker帐户中。

But, when I am pulling the same container I am not able to see the data which I stored in the container. 但是,当我拉同一个容器时,看不到存储在容器中的数据。 Why my data is not available? 为什么我的数据不可用?

Where has my data gone? 我的数据去了哪里?

UPDATE 更新

I performed following steps: 我执行了以下步骤:

ubuntu@domU-12-31-39-0A-11-9F:~$ sudo docker run -i -t ubuntu /bin/bash ubuntu @ domU-12-31-39-0A-11-9F:〜$ sudo docker run -i -t ubuntu / bin / bash

Unable to find image 'ubuntu' locally Pulling repository ubuntu 无法在本地找到映像“ ubuntu”

xxxxxxxxxxxx: Download complete xxxxxxxxxxxx: Download complete xxxxxxxxxxxx: Download complete xxxxxxxxxxxx: Download complete xxxxxxxxxxxx: Download complete xxxxxxxxxxxx: Download complete xxxxxxxxxxxx: Download complete xxxxxxxxxxxx: Download complete xxxxxxxxxxxx: Download complete xxxxxxxxxxxx: Download complete xxxxxxxxxxxx: Download complete xxxxxxxxxxxx:下载完成xxxxxxxxxxxx:下载完成xxxxxxxxxxxx:下载完成xxxxxxxxxxxx:下载完成xxxxxxxxxxxx:下载完成xxxxxxxxxxxx:下载完成xxxxxxxxxxxx:下载完成xxxxxxxxxxxx:下载完成xxxxxxxxxxxx:下载完成xxxxxxxxxxxx:下载完成xxxxxxxxxxxx:下载完成

root@xxxxxxxxxxxx: root @ xxxxxxxxxxxx:

Here I did the changes and then I commited the container 在这里,我做了更改,然后提交了容器

ubuntu@domU-12-31-39-07-76-B4:~$ sudo docker commit xxxxxxxxxxxx ubuntu 0fd6b6b8acd3dc49947611e61077600a93a6285ebdcf45f1a8f73b4a26274fee ubuntu @ domU-12-31-39-07-76-B4:〜$ sudo docker commit xxxxxxxxxxxx ubuntu 0fd6b6b8acd3dc49947611e61077600a93a6285ebdcf45f1a8f73b4a26274fee

ubuntu@domU-12-31-39-07-76-B4:~$ sudo docker push myrepositoryname/ubuntu The push refers to a repository [myrepositoryname/ubuntu] (len: 1) Sending image list ubuntu @ domU-12-31-39-07-76-B4:〜$ sudo docker push myrepositoryname / ubuntu推送引用存储库[myrepositoryname / ubuntu](len:1)发送图像列表

Please login prior to push: Username: xxxx Password: Email: xxxxxxxx Login Succeeded The push refers to a repository [myrepositoryname/ubuntu] (len: 1) Sending image list Pushing repository myrepositoryname/ubuntu (1 tags) 511136ea3c5a: Image already pushed, skipping Image xxxxxxxxxxxx already pushed, skipping Image xxxxxxxxxxxx already pushed, skipping Image xxxxxxxxxxxx already pushed, skipping Pushing tag for rev [xxxxxxxxxxxx] on {https:// repository name} 请在推送之前登录:用户名:xxxx密码:电子邮件:xxxxxxxx登录成功推送指的是存储库[myrepositoryname / ubuntu](len:1)发送图像列表推送存储库myrepositoryname / ubuntu(1个标签)511136ea3c5a:已推送图像,跳过图像xxxxxxxxxxxx已推送,跳过图像xxxxxxxxxxxx已推送,跳过图像xxxxxxxxxxxx已推送,跳过{https://存储库名称}上的rev [xxxxxxxxxxxx]推送标签

After it I checked in my docker account, the image got pushed. 之后,我签入了docker帐户,图像被推送。 After that I created a new account and pulled the image (I made the image public). 之后,我创建了一个新帐户并提取了图像(将图像公开)。 But,I am not getting my data 但是,我没有得到我的数据

ubuntu@domU-12-31-39-14-1D-8F:~$ sudo docker login ubuntu @ domU-12-31-39-14-1D-8F:〜$ sudo docker 登录

Username: xxxx Password: Email: xxxxxxxxxxxx Account created. 用户名:xxxx密码:电子邮件:xxxxxxxxxxxx创建帐户。 Please use the confirmation link we sent to your e-mail to activate it. 请使用我们发送到您的电子邮件的确认链接将其激活。

ubuntu@domU-12-31-39-14-1D-8F:~$ sudo docker login ubuntu @ domU-12-31-39-14-1D-8F:〜$ sudo docker登录

Username (xxxx): xxxxx 用户名(xxxx):xxxxx

Login Succeeded 登录成功

ubuntu@domU-12-31-39-14-1D-8F:~$ sudo docker pull myrepositoryname/ubuntu ubuntu @ domU-12-31-39-14-1D-8F:〜$ sudo docker pull myrepositoryname / ubuntu

Pulling repository myrepositoryname/ubuntu 6d38862b09be: Download complete 511136ea3c5a: Download complete 6170bb7b0ad1: Download complete 9cd978db300e: Download complete 拉存储库myrepositoryname / ubuntu 6d38862b09be:下载完成511136ea3c5a:下载完成6170bb7b0ad1:下载完成9cd978db300e:下载完成

ubuntu@domU-12-31-39-14-1D-8F:~$ sudo docker run -i -t myrepositoryname/ubuntu /bin/bash ubuntu @ domU-12-31-39-14-1D-8F:〜$ sudo docker run -i -t myrepositoryname / ubuntu / bin / bash

root@7b7cc51fbd90:/# cd home/ root@7b7cc51fbd90:/home# ls root @ 7b7cc51fbd90:/#cd主页/ root @ 7b7cc51fbd90:/ home#ls

I stored my data in /home path but when I am checking there is no data 我将数据存储在/ home路径中,但是当我检查时没有数据

Did you create an image? 您创建图像了吗?

When you docker run an image (with n file layers, see http://docs.docker.io/en/latest/terms/layer/ ) you create an n+1 'th file layer on top of that. docker run映像(具有n文件层,请参阅http://docs.docker.io/en/latest/terms/layer/ )时,您将在此之上创建第n+1个文件层。 That is where you stored your data in. If you docker stop your container, that data remains in that layer, and when you re- docker start your container the data is still there. 那就是您存储数据的地方。如果docker stop容器,该数据将保留在该层中,而当您重新docker start容器时,该数据仍将存在。

However, if you docker run your image again, you make a different container which does not have that data. 但是,如果docker run再次docker run映像,则会创建一个不包含该数据的其他容器。

Now, you want to send your data to the index (your Docker account). 现在,您想将数据发送到索引(您的Docker帐户)。 You can only send images, not containers, and the image you used does not contain this data. 您只能发送图像,不能发送容器,并且您使用的图像不包含此数据。 Therefore, you need to docker commit your container to a new image, and the you can docker push the resulting image. 因此,您需要docker commit您的容器docker commit到新映像,然后您可以docker push入结果映像。 docker pull ing that should give you a startable image containing the data. docker pull应该会为您提供一个包含数据的可启动映像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM