Now that I've finally started learning Docker, I'll summarize my understanding.
docker-compose up
!Assuming you have a key pair in ~ / .ssh
on your local PC
cd ~/.ssh
ssh -i "ec2-key.pem" ec2-user@<public-ip>
ssh-keygen -t rsa
You will be asked for a passphrase, so enter the passphrase if necessary.
If the key is created correctly, two files will be created under ~ / .ssh
, ʻid_rsa and ʻid_rsa.pub
.
Since ʻid_rsa.pub` is the public key, you will need to register its contents in Deploy Key on github.
Make a copy of this public key.
cat ~/.ssh/id_rsa.pub
You can register on the SSH key registration page.
For Title, enter a text that shows the contents of the key, and paste the public key you copied earlier into Key.
ssh -T [email protected]
git clone [email protected]:yourname/yourrepo.git
docker-compose up
!Before that, I'm sorry.
sudo service docker start
And
docker-compose up
That is an error for some reason. .. ..
ʻError: Cannot find module What is'express'? Isn't it properly written in
package.json`? .. ..
Creating express-app ... done
Creating nginx-web ... done
Attaching to express-app, nginx-web
express-app | node:internal/modules/cjs/loader:903
express-app | throw err;
express-app | ^
express-app |
express-app | Error: Cannot find module 'express'
express-app | Require stack:
express-app | - /usr/src/app/index.js
express-app | at Function.Module._resolveFilename (node:internal/modules/cjs/loader:900:15)
express-app | at Function.Module._load (node:internal/modules/cjs/loader:745:27)
express-app | at Module.require (node:internal/modules/cjs/loader:972:19)
express-app | at require (node:internal/modules/cjs/helpers:88:18)
express-app | at Object.<anonymous> (/usr/src/app/index.js:1:17)
express-app | at Module._compile (node:internal/modules/cjs/loader:1083:30)
express-app | at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:10)
express-app | at Module.load (node:internal/modules/cjs/loader:948:32)
express-app | at Function.Module._load (node:internal/modules/cjs/loader:789:14)
express-app | at Function.executeUserEntryPoint [as runMain](node:internal/modules/run_main:72:12) {
express-app | code: 'MODULE_NOT_FOUND',
express-app | requireStack: [ '/usr/src/app/index.js' ]
express-app | }
nginx-web | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx-web | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx-web | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx-web | 10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
express-app exited with code 1
nginx-web | 10-listen-on-ipv6-by-default.sh: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
nginx-web | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx-web | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx-web | 2020/10/24 02:42:13 [emerg] 1#1: host not found in upstream "app" in /etc/nginx/nginx.conf:18
nginx-web | nginx: [emerg] host not found in upstream "app" in /etc/nginx/nginx.conf:18
nginx-web exited with code 1
As a result of various investigations, it seems that something difficult is happening.
Follow the advice and fix docker-compose.yml
.
docker-compose.yml
volumes:
- './app:/usr/src/app'
- usr/src/app/node_modules #Postscript
This was pretty good!
Recommended Posts