인프라/도커
-
컨테이너에서 Docker 명령어 사용하기인프라/도커 2024. 1. 13. 03:36
도커 컨테이너에서 젠킨스를 실행하고, build를 진행하는 과정에서 발생한 이슈를 해결해봅니다. 도커 컨테이너에서 docker 명령어를 실행하려면 어떻게 해야할까요 도커를 사용해서 띄운 컨테이너지만, 격리된 공간이기 때문에 컨테이너 내부에는 별도로 도커를 설치하지 않는 이상 도커의 존재를 모르는 상태입니다. 그렇다면 그냥 도커를 설치하면 되는 것 일까요? gpt에게 물어보니 몇 가지 방법이 있다고 합니다. Docker-in-Docker Docker 외부실행 Docker 소켓마운트 저는 소켓마운트 방법을 사용해서 문제를 해결해보도록 하겠습니다. 제가 사용하고 있는 젠킨스에 호스트의 Docker 소켓을 연결하고 컨테이너 속에서 도커 클라이언트를 설치해서 사용하겠습니다. 1. Docker 소켓 마운트 도커 컨..
-
컨테이너와 컨테이너 사이의 통신인프라/도커 2024. 1. 3. 21:47
지난 글에 이어서 서버와 DB를 함께 다양한 환경에서 사용해보겠습니다. 아래 순서로 글을 진행해보겠습니다. - 호스트와 컨테이너 사이의 통신 1. DB (호스트) & 서버 (호스트) 실행시키기 2. DB (호스트) & 서버 (도커) 실행시키기 3. DB (도커) & 서버 (호스트) 실행시키기 - 컨테이너 사이의 통신 4. 한 개의 컨테이너에서 DB & 서버 실행시키기 5. 각각 다른 컨테이너에서 DB & 서버 실행시키기 6. 도커 컴포즈로 DB & 서버 관리하기 4. 한 개의 컨테이너에서 DB & 서버 실행시키기 로컬 환경에서 DB와 서버를 한 곳에서 실행시키 듯이 컨테이너에서도 가능은 합니다. 스프링 서버와 mysql을 실행시킬 수 있는 환경을 컨테이너에 구현합니다. # Ubuntu 베이스 이미지 사용..
-
호스트와 컨테이너 사이의 통신인프라/도커 2024. 1. 3. 17:13
지난 글에 이어서 서버와 DB를 함께 다양한 환경에서 사용해보겠습니다. 아래 순서로 글을 진행해보겠습니다. - 호스트와 컨테이너 사이의 통신 1. DB (호스트) & 서버 (호스트) 실행시키기 2. DB (호스트) & 서버 (도커) 실행시키기 3. DB (도커) & 서버 (호스트) 실행시키기 - 컨테이너 사이의 통신 4. 한 개의 컨테이너에서 DB & 서버 실행시키기 5. 각각 다른 컨테이너에서 DB & 서버 실행시키기 6. DB & 서버 도커 컴포즈로 관리하기 1. DB (호스트) & 서버 (호스트) 실행시키기 기본적으로 프로젝트 생성시 사용하는 세팅입니다. localhost의 8080 포트와 3306 포트에서 서버와 db를 각각 실행합니다. 스프링 cli를 이용해서 프로젝트를 생성하고 8080에 접속..
-
호스트 빌드에서 도커의 멀티 스테이지 빌드까지인프라/도커 2024. 1. 3. 01:22
도커에 익숙해지기 위한 몇 가지 실습들을 진행해보았습니다. 아래 순서로 글을 진행해보겠습니다. 1. 로컬에서 스프링 프로젝트 빌드해서 실행하기 2. 로컬에서 빌드한 파일을 컨테이너에서 실행시키기 3. 컨테이너에서 빌드 후 실행시키기 4. 멀티스테이지 빌드 후 실행시키기 1. 로컬에서 빌드해서 실행하기 개발환경에서 가장 기초적으로 사용하는 세팅입니다. localhost에서 서버를 띄우는 세팅입니다. 스프링 cli를 이용해서 프로젝트를 생성하고 8080에 접속했을 때 'Hello World'가 보이도록 index.html을 추가합니다. $ spring init --dependencies=web myserver 빌드명령어를 실행해서 jar파일을 생성합니다. $ ./gradlew build 빌드된 파일을 실행시..
-
자주 쓰이는 도커 명령어 정리인프라/도커 2023. 12. 21. 12:46
손에 완전히 익을 때 까지 빠르게 찾기 위한 용도로 자주 쓰는 도커 명령어를 좀 정리해봅니다. - run// -i + -t의 조합// 터미널 실행$ docker run -it ubuntu// --rm// 터미널 세션이 종료되면 컨테이너 삭제$ docker run -it --rm ubuntu// --cpus [코어 수]// 컨테이너에 cpu 코어 3개를 할당해서 실행$ docker run -i --cpus 3 eclipse-temurin:17-jdk// --cpuset-cpu [코어 목록의 시작 인덱스 - 끝 인덱스]// 컨테이너에 인덱스 범위에 해당되는 코어를 할당해서 실행$ docker run -i --cpuset-cpu 0-2 eclipse-temurin:17..