20200929 映像與倉庫 (二)
Last updated
Last updated
docker search httpd
docker login
docker pull centos
docker images
cd
systemctl start sshd
開啟 PuTTY
docker pull rackspacedot/python37
cd /var/lib/docker
cd image
cd overlay2
docker images
docker run -it busybox:latest sh
ifconfig
ping www.google.com
exit
docker ps -a
docker run -it busybox:1 echo "hello world"
docker pull gcc
docker run -it -v /data:/data gcc:latest bash
cd /data
cat hello.c
gcc -o hello hello.c
exit
docker pull codenvy/python27
mkdir -p /data
cd /data
vim hello.c
#include <stdlib.h>
#include <stdio.h>
int main(){
printf("hello world\n");
return 0;
}
./hello
vim p2.py
[Service]
print "hello world"
vim p3.py
print ("hello world")
cat p2.py
cat p3.py
一次就可以刪除已經不在執行的容器
docker rm -f `docker ps -a -q`
docker rmi
要確保沒有任何相關容器正在運行
docker run -it --rm busybox:latest echo "hello"
cd /data
mkdir -p /myweb
cd /myweb
echo "hello world" > index.html
docker run -itd --name myweb1 -p 8080:80 httpd
docker run -itd --name myweb2 -v /myweb: docker run -it --rm busybox:latest echo "hello" -p 8080:80 httpd
docker run -itd --name myweb2 -v /myweb:/usr/local/apache2/htdoc -p 8080:80 httpd
docker run -itd --name myweb3 -v /myweb:/usr/local/apache2/htdoc -p 8080:80 httpd
docker exec -it myweb3 bash
cd htdoc
cat index.html
exit
docker rm -f myweb3
docker run -itd --name myweb3 -v /myweb:/usr/local/apache2/htdocs -p 8081:80 httpd
docker run -itd --name myweb4 -p 8082:80 httpd
cd /myweb
docker cp index.html myweb4:/usr/local/apache2/htdocs
docker commit [容器ID] [xiaoji850312/鏡像名稱]:v1
docker run -itd --name myweb5 -p 8083:80 xiaoji850312/myweb4:v1
docker ps
docker attach [容器ID]