클라우드 네이티브 애플리케이션 부트캠프 알림

티스토리 뷰

작업하는 PC나 VM에서 ubuntu나 centos를 container로 실행하는 방법입니다.

centos

2020-06-02현재 centos8까지 나와 있습니다.

최신 버전

아래와 같이 실행하면 됩니다.  
> docker run -it centos sh
sh-4.4# exit
exit

container를 종료하면 아래 명령으로 중단된 container를 보고 다시 실행할 수 있습니다. 

❯ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
d02a9cbdfa50        centos              "sh"                9 seconds ago       Exited (0) 6 seconds ago                       agitated_gates
b97449acab2d        centos7             "sh"                About an hour ago   Up About an hour                               nervous_wu

~
❯ docker start d0
d0

~
❯ docker exec -it d0 sh
sh-4.4# exit
exit

centos7

❯ docker search centos
NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
centos                             The official build of CentOS.                   6029                [OK]
ansible/centos7-ansible            Ansible on Centos7                              129                                     [OK]

❯ docker pull ansible/centos7-ansible

❯ docker tag ansible/centos7-ansible centos7
❯ docker run -it centos7 sh
sh-4.2# ls
CHANGELOG.md          COPYING            Makefile      ROADMAP.rst            bin      docs-api  hacking      setup.py     ticket_stubs
CODING_GUIDELINES.md  MANIFEST.in        README.md      VERSION            contrib  docsite   lib      shippable.yml  tox.ini
CONTRIBUTING.md       MODULE_GUIDELINES.md  RELEASES.txt  ansible-core-sitemap.xml  docs     examples  packaging  test
sh-4.2# exit
exit

~
❯ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

~
❯ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
4a50adcba0e8        centos7             "sh"                9 seconds ago       Exited (0) 4 seconds ago                       musing_montalcini

~
❯ docker start 4a
4a

~
❯ docker exec -it 4a sh
sh-4.2#

ubuntu

❯ docker run -it ubuntu sh
# ls
bin  boot  dev    etc  home  lib    lib32  lib64  libx32  media  mnt  opt  proc  root  run    sbin  srv  sys    tmp  usr  var
# exit

~
❯ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES
4a50adcba0e8        centos7             "sh"                About a minute ago   Up About a minute                       musing_montalcini

~
❯ docker exec -it 4a sh
sh-4.2# pwd
/opt/ansible/ansible
sh-4.2# cd && pwd
/root

'Cloud > Docker' 카테고리의 다른 글

Docker 주요 명령  (1) 2020.11.15
docker 오프라인(offline) 설치 for centos, redhat(RHEL)  (3) 2020.10.15
6. Beyond Docker  (0) 2019.09.12
5. More Advanced  (0) 2019.09.12
4. Getting Started  (0) 2019.09.12
댓글

클라우드 네이티브 애플리케이션 부트캠프 알림