suzuki-hoge / docker-practice Goto Github PK
View Code? Open in Web Editor NEWProject template and sample files for Docker Practice
Home Page: https://zenn.dev/suzuki_hoge/books/2022-03-docker-practice-8ae36c33424b59
Project template and sample files for Docker Practice
Home Page: https://zenn.dev/suzuki_hoge/books/2022-03-docker-practice-8ae36c33424b59
有用な書籍の公開ありがとうございます。
書籍の手順に沿って操作したつもりですが、ファイルの存在を確認できませんでした。
私はどこを理解できていませんか?
ご教示くだされば幸いです。
実行環境: Ubuntu20.04を使用
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS"
$ docker --version
Docker version 20.10.18, build b40c2f6
操作
ターミナルにて
// コンテナが存在しないことを確認
$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ docker container run \
--name ubuntu1 \
--rm \
--interactive \
--tty \
ubuntu:20.04
root@fe5fd49c4bcf:/# echo 'hello world' > ~/hello.txt
root@fe5fd49c4bcf:/#
同一ターミナルにタブを追加して
// コンテナの状況を確認 `CONTAINER ID`, `NAME` 共にOK
$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fe5fd49c4bcf ubuntu:20.04 "bash" 27 seconds ago Up 26 seconds ubuntu1
// NAMESに合わせて...
$ docker container exec \
> ubuntu1 \
> cat ~/hello.txt
cat: /home/loginname/hello.txt: No such file or directory
CONTAINER ID
でも結果は同様です。
$ docker container exec fe5fd49c4bcf cat ~/hello.txt
cat: /home/loginname/hello.txt: No such file or directory
No such file or directory
ファイルの存在を確認できません。
最初のターミナルタブに戻ってファイルを確認すると存在しています。
root@fe5fd49c4bcf:/# cat ~/hello.txt
hello world
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.