kubernetes에서 배포 이미지 생성시 유의 사항은 다음과 같다.




https://kubernetes.io/docs/concepts/containers/images/#updating-images



imagePullPolicy의 기본값은 IfNotPresent이다. 이미 존재하면 계속 사용한다는 점이다.


예를 들어 image:lastest를 사용 중이라면 IfNotPresent라면 한번만 이미지를 다운받고 다시 pod를 재시작하지 않는다.


따라서 똑같은 에러가 계속 발생한다.


이 문제를 해결하려면


imagePullPolicy를 Always로 변경해야 한다.





만약 tag를 사용해 버전닝을 하는 경우라면 imagePullPolicy의 값을 IfNotPresent로 설정하는 것이 좋다.





Posted by 김용환 '김용환'

댓글을 달아 주세요

docker 이미지가 alpine이라면 /bin/bash를 지원하지 않을 수 있다. /bin/bash을 지원하는 sh가 많아지고 있다.




$ docker exec -it 9198cbd7a9da /bin/bash

OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown


이 때는 /bin/sh를 사용한다.


$ docker exec -it 9198cbd7a9da /bin/sh

/app # ps -ef


(나도 모르게 늘 bash를 사용한다..ㅠ)

Posted by 김용환 '김용환'

댓글을 달아 주세요

  1. Favicon of https://ohoroyoi.tistory.com BlogIcon 한만큼 2019.07.16 15:24 신고  댓글주소  수정/삭제  댓글쓰기

    감사합니다!!


docker build 할 때 이미지를 한 번 다운로드하면 캐싱하는 것이 정책이다.


따라서 no-cache 옵션을 변경해서 매번 docker build할 때 마다 이미지를 생성하도록 한다.


--no-cache=true


https://docs.docker.com/engine/reference/commandline/build/






Posted by 김용환 '김용환'

댓글을 달아 주세요



도커 환경을 정리하는 커맨드가 여럿 있다.




· docker container prune은 중지된 모든 컨테이너를 삭제한다.


· docker image prune은 이름 없는 모든 이미지를 삭제한다.


· docker network prune은 사용되지 않는 도커 네트워크를 모두 삭제한다.


· docker volume prune은 도커 컨테이너에서 사용하지 않는 모든 도커 볼륨을 삭제한다.


· docker system prune -a는 중지된 모든 컨테이너, 사용되지 않은 모든 네트워크, 하나 이상의 컨테이너에서 사용되지 않는 모든 이미지를 삭제한다. 따라서 남아있는 컨테이너 또는 이미지는 현재 실행 중인 컨테이너에서 필요하다.



Posted by 김용환 '김용환'

댓글을 달아 주세요



 docker-compose up 커맨드는 모든 서비스를 결합한 표준 출력을 리턴한다. 


모든 로그의 표준 출력을 본다해도 거의 도움이 되지 않아서 


docker-compose up -d를 사용하는 것이 더 나은 선택이다. 


docker-compose up -d 커맨드를 사용하면 표준 출력을 리턴하지 않는다. 


https://docs.docker.com/compose/reference/up/

Posted by 김용환 '김용환'

댓글을 달아 주세요


docker 컨테이너 로그를 계속 보고 싶다면(tail -f효과)를 다음 url을 확인할 수 있다.


https://docs.docker.com/engine/reference/commandline/container_logs/#related-commands


docker logs --tail 커맨드를 사용한다.




docker logs -f --tail  --it $container-ps-id


docker logs --follow --tail  --it $container-ps-id

Posted by 김용환 '김용환'

댓글을 달아 주세요



docker 17.07 버전부터 좀 쉽게.. proxy 설정을 할 수 있다. 


참고 https://docs.docker.com/network/proxy/#configure-the-docker-client


도커 클라이언트에서 아래 설정 파일에 

~/.docker/config.json



다음 내용을 추가한다.



{
 "proxies":
 {
   "default":
   {
     "httpProxy": "http://127.0.0.1:3001",
     "noProxy": "*.test.example.com,.example2.com"
   }
 }
}


Posted by 김용환 '김용환'

댓글을 달아 주세요



ubunt 16.04에서 docker 재설치 가이드이다. 



기존 환경은 docker 1.11인데, 최신인 docker ce(18.03.1-ce)을 설치한다. 

https://docs.docker.com/install/linux/docker-ce/ubuntu/#set-up-the-repository


root 사용자로 진행한다.



$ apt-get remove docker docker-engine docker.io


$ rm /etc/systemd/system/docker.service.d/docker.conf


$ setproxy apt-get update


$ apt-get install \

    apt-transport-https \

    ca-certificates \

    curl \

    software-properties-common



PROXY를 셋팅한다.

$ export ..



$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -

OK



$ apt-key fingerprint 0EBFCD88

pub   4096R/0EBFCD88 2017-02-22

      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88

uid                  Docker Release (CE deb) <docker@docker.com>

sub   4096R/F273FCD8 2017-02-22




$ sudo add-apt-repository \

   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \

   $(lsb_release -cs) \

   stable"


$ apt-get update

   

$ apt-get install docker-ce


$ docker version

Client:

 Version:      18.03.1-ce

 API version:  1.37

 Go version:   go1.9.5

 Git commit:   9ee9f40

 Built:        Thu Apr 26 07:17:20 2018

 OS/Arch:      linux/amd64

 Experimental: false

 Orchestrator: swarm


Server:

 Engine:

  Version:      18.03.1-ce

  API version:  1.37 (minimum version 1.12)

  Go version:   go1.9.5

  Git commit:   9ee9f40

  Built:        Thu Apr 26 07:15:30 2018

  OS/Arch:      linux/amd64

  Experimental: false



$ service docker start 








만약 proxy 이슈라면 다음을 실행한다. 




$ setproxy apt-get update


$ setproxy apt-get install docker-ce


$ service docker start 



$ docker version

Client:

 Version:      18.03.1-ce

 API version:  1.37

 Go version:   go1.9.5

 Git commit:   9ee9f40

 Built:        Thu Apr 26 07:17:20 2018

 OS/Arch:      linux/amd64

 Experimental: false

 Orchestrator: swarm


Server:

 Engine:

  Version:      18.03.1-ce

  API version:  1.37 (minimum version 1.12)

  Go version:   go1.9.5

  Git commit:   9ee9f40

  Built:        Thu Apr 26 07:15:30 2018

  OS/Arch:      linux/amd64

  Experimental: false

  

  

참고

https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce-1




Posted by 김용환 '김용환'

댓글을 달아 주세요



https://blog.docker.com/2018/01/docker-mac-kubernetes/



이제 맥 docker에서 k8s를 사용할 수 있게끔 한다고 한다.






Posted by 김용환 '김용환'

댓글을 달아 주세요

[docker] ipv6 지원

docker 2017. 11. 24. 10:55


docker에서는 ipv6를 기본으로 지원하지 않고, --ipv6 옵션을 줘야 활성화된다.


https://docs.docker.com/engine/userguide/networking/default_network/ipv6/


By default, the Docker daemon configures the container network for IPv4 only. You can enable IPv4/IPv6 dualstack support by running the Docker daemon with the --ipv6 flag. Docker will set up the bridge docker0 with the IPv6 link-local address fe80::1.

Posted by 김용환 '김용환'

댓글을 달아 주세요