Skip to content

Instantly share code, notes, and snippets.

@hyunjun
Last active December 14, 2021 07:30
Show Gist options
  • Save hyunjun/c4ce053c28bd5df8b890aeae19af4270 to your computer and use it in GitHub Desktop.
Save hyunjun/c4ce053c28bd5df8b890aeae19af4270 to your computer and use it in GitHub Desktop.
docker example
  • https://qiita.com/Eliza_wb/items/ff3d885d78ff870191ab

  • Docker는 GUI 설치가 되어 있고, docker 유저로 GUI로 실행했다고 상정

  • 설정 .bashrc

    # jetbrains 제품의 위치를 지정
    CLHOME=$HOME/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/173.4301.33
    CLCONF=.CLion2017.3
    PYCHOME=$HOME/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/181.3007.3/
    PYCCONF=.PyCharm2018.1
    
    function jb_gui() {
      docker run --privileged -it --rm  \
      -e DISPLAY=$DISPLAY \
      -v /tmp/.X11-unix:/tmp/.X11-unix:rw \ #X 소켓을 공유
      -v $HOME/.gitconfig:/home/docker/.gitconfig \ # git 설정
      -v $CLHOME:/home/docker/clion \ # clion
      -v $HOME/${CLCONF}:/home/docker/${CLCONF} \ # clion 설정
      -v $PYCHOME:/home/docker/pycharm \ # pycharm
      -v $HOME/${PYCCONF}:/home/docker/${PYCCONF} \ # pycharm 설정
      -v $HOME/.java:/home/docker/.java \ # 라이센스 정보
      -v /work:/work \ # 프로젝트 디렉토리를 호스트와 같은 위치에 마운트 하면 아주 빠르다
      IMAGE_TAG /bin/bash
    }
    
  • 실행

    eliza@eliza-pc:~$ jb_gui
    docker@eliza-pc:~$ ~/clion/bin/clion.sh &
    
  • https://hub.docker.com/_/python/

  • python script 그냥 실행하기

    $ sudo docker run --rm -it python python
    Python 3.6.3 (default, Nov  4 2017, 22:17:09)
    [GCC 4.9.2] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    
  • script 실행하기

    $ cat test.sh
    #!/bin/sh
    python
    
    $ sudo docker run -v `pwd`/test.sh:/test.sh -it python bash -c "/test.sh"
    Python 3.6.3 (default, Nov  4 2017, 22:17:09)
    [GCC 4.9.2] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment