【2】docker 기본 조작.md

1494 단어
【2】 docker 기본 조작
기본 명령

docker info                           # 
   docker     
docker pull ubuntu                    #        
docker inspect ubuntu                 #       
docker run -i -t ubuntu /bin/bash     #       
docker ps -a                          #       

예제

#         

JOB=$(docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done")

#       
docker logs \$JOB

#
     
docker kill \$JOB

#         
docker ps

#       

docker ps -a


컨테이너 작업

#     

JOB=$(docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done")

#     

docker stop \$JOB

#     

docker start \$JOB

#     

docker restart \$JOB

#     

docker kill \$JOB

#     (     )

docker stop \$JOB

docker rm \$JOB

#       

docker rm \$(docker ps -qa | xargs)


TCP 포트에 서비스 바인딩

#       4444  ,  netcat  

JOB=$(docker run -d -p 4444 ubuntu /bin/nc -l 4444)

#         

PORT=$(docker port \$JOB 4444 | awk -F: '{ print \$2 }')

#        

echo hello world | nc 127.0.0.1 \$PORT

#         

echo "Daemon received: \$(docker logs \$JOB)"


커밋(저장) 컨테이너 상태

#         

docker commit  

#     

docker save -o ubuntu_14.04.3.tar ubuntu

#     

docker load --input ubuntu_14.04.3.tar

docker load < ubuntu_14.04.3.tar

#     
docker images

좋은 웹페이지 즐겨찾기