# Ubuntu Docker

Ubuntu에서 docker 설치

1. `sudo apt update`
2. sudo apt install apt-transport-https ca-certificates curl software-properties-common
3. curl -fsSL<https://download.docker.com/linux/ubuntu/gpg> | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
4. echo "deb \[arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]<https://download.docker.com/linux/ubuntu> $(lsb\_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
5. sudo apt update
6. apt-cache policy docker-ce
7. sudo apt install docker-ce
8. sudo systemctl status docker
9. sudo apt install docker-compose

sudo docker ps

sudo docker-compose up -d // 백그라운드에서 실행

* **`sudo docker-compose down`**: 현재 실행 중인 Docker 컨테이너를 중지하고, 관련된 네트워크와 볼륨을 제거
* **`sudo docker-compose stop`**: 현재 실행 중인 Docker 컨테이너를 중지하지만, 관련된 네트워크와 볼륨은 제거하지 않음
* **`sudo docker-compose rm`**: 중지된 Docker 컨테이너를 제거
* **`sudo docker-compose kill`**: Docker 컨테이너를 강제 종료

***

git clone

#### nodejs 설치방법

nodejs 버전관리 도구 n 설치

sudo apt-get install npm sudo npm install -g n

#### yarn 설치방법

1. npm install -g yarn
2. yarn -v

***

#### 메모리 swap

1. sudo dd if=/dev/zero of=/mnt/swapfile bs=1M count=2048
2. sudo mkswap /mnt/swapfile
3. sudo swapon /mnt/swapfile

#### 메모리 확인

free -h

<figure><img src="https://4260850757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbYcvv7IylJ9jaNhqGBno%2Fuploads%2F4JBitm927lhT4iRkDcOx%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202023-05-16%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%203.00.24.png?alt=media&#x26;token=099c66db-b47a-4354-9ed1-c9554b57410f" alt=""><figcaption></figcaption></figure>

reference: <https://progdev.tistory.com/26>

***

client/

yarn

*sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000*

yarn add pm2 -g

yarn run build:prod

***

* \[ ] 오류 pm2 Command not found

```bash
위의 결과에서 pm2가 /usr/local/bin에 설치되어있는 것이 아닌 node_modules/.bin/pm2에 설치되어 있습니다. 따라서 /usr/local/bin에 경로를 추가해도 pm2 명령어를 인식하지 못하는 것입니다.

그러므로 pm2 start ecosystem.config.js 대신에 ./node_modules/.bin/pm2 start ecosystem.config.js 명령어를 사용하시면 pm2를 실행할 수 있을 것입니다.
```

실행

**`./node_modules/.bin/pm2 start ecosystem.config.js`**

종료

**`./node_modules/.bin/pm2 stop inplace-client`**

`**./node_modules/.bin/pm2 stop inplace-server**`

pm2 monit

find \* -name "pm2”

***

***
