docker save [option] [tar filename] [image name]
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest fa5269854a5e 2 weeks ago 142MB
docker save -o test.tar fa5269854a5e
실행중인 컨테이너를 export 하는 방법
docker export [container name or containter ID] > [tar filename]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
791601bf0587 nginx:latest "/docker-entrypoint.…" 33 minutes ago Up 33 minutes 0.0.0.0:80->80/tcp mystifying_benz
docker export 791601bf0587 > test.tar
위에서는 docker를 실행할 때 /Users/Workspaces/docker 경로를 컨테이너 안에 /usr/share/nginx/html 에 바인드 시켰다. 기본적으로 nginx의 /usr/share/nginx/html 경로에는 index.html 파일이 존재하지만 현재 호스트의 /Users/Workspaces/docker 경로에는 아무것도 없는 빈 디렉토리이기 때문에 403 이 나온다.
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[kubelet-check] Initial timeout of 40s passed.
Unfortunately, an error has occurred:
timed out waiting for the condition
This error is likely caused by:
- The kubelet is not running
- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
- 'systemctl status kubelet'
- 'journalctl -xeu kubelet'
Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI, e.g. docker.
Here is one example how you may list all Kubernetes containers running in docker:
- 'docker ps -a | grep kube | grep -v pause'
Once you have found the failing container, you can inspect its logs with:
- 'docker logs CONTAINERID'
error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster
1. docker Cgroup 이 systemd 로 설정되어있을 경우
/etc/docker/daemon.json 파일에 아래 문구 추가한다.
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
그리고 systemctl daemon-reload systemctl restart docker
2. 로그 확인
- 'journalctl -xeu kubelet'
이 명령어를 실행 하면 아래와 같이 로그가 남았다.
Apr 30 22:19:38 master kubelet: W0430 22:19:38.226441 2372 cni.go:157] Unable to update cni config: No networks found in /etc/cni/net.d
Apr 30 22:19:38 master kubelet: E0430 22:19:38.226587 2372 kubelet.go:2067] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
내 경우에는 위에 2. /env/environment 설정 에 보면 **no_proxy** 항목에 현재 K8S 가 설치된 Machine 의 IP 를 추가했더니 해결이 되었다.
- kubeadm join 했는데 다음과 같이 나올 경우
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists
[ERROR Port-10250]: Port 10250 is in use
[ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
VM 에서 다음과 같이 kubeadm join 을 했는데 에러가 났을경우 (node가 2개인데 2번째 노드 구성시)
An application image with a v1 tag has been pushed to the gcr.io repository A new Kubernetes cluster exists (zone: us-central1-a) Check that an application has been deployed to the cluster Test that a service exists that responds to requests like Echo-app
여기에서 난 1번을 선택해서 적용을 했는데 한가지 Dockerfile 에 전달되는 profile 값이 변경 될수 있도록 하고 싶었다. 그럴려면 docker build 시점에 값을 넘겨줘야 하는데 document를 찾아보니 ARG 를 사용하게 되면 docker build 시점에 값을 넘길수가 있다.
FROM ubuntu
VOLUME /tmp
ADD app.jar app.jar
RUN bash -c 'touch ./app.jar'
ARG SPRING_PROFILES_ACTIVE
RUN echo $SPRING_PROFILES_ACTIVE
ENV SPRING_PROFILES_ACTIVE=$SPRING_PROFILES_ACTIVE
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom", "-jar","./app.jar"]
결과적으로 docker build 시에 --build-arg 로 SPRING_PROFILES_ACTIVE 값을 넘겨주고 Dockerfile 에서는 전달 받은 SPRING_PROFILES_ACTIVE 값을 ENV 로 등록을하면 ENTRYPOINT 에 -D 옵션을 넣어서 실행하지 않아도 자동으로 profile 이 적용되서 실행이 된다.