Skip to content

Instantly share code, notes, and snippets.

@bkrajendra
Forked from npearce/install-docker.md
Last active July 30, 2023 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkrajendra/4b9943918b9e0752563a0ac24605d53e to your computer and use it in GitHub Desktop.
Save bkrajendra/4b9943918b9e0752563a0ac24605d53e to your computer and use it in GitHub Desktop.
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE: 29-07-2023 - use native method for Amazon Linux 2023 at https://docs.docker.com/engine/install/centos/

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user

Make docker auto-start

sudo chkconfig docker on

Because you always need it....

sudo yum install -y git

Reboot to verify it all loads fine on its own.

sudo reboot

docker-compose install

Copy the appropriate docker-compose binary from GitHub:

DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.20.2/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose

Fix permissions after download:

sudo chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose

Verify success:

docker compose version

install nvm and node:

sudo yum install -y gcc gcc-c++ make openssl-devel git


 curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -
 sudo yum install nodejs
 cd ~
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'

nano .bashrc

add:
export PATH=~/.npm-global/bin:$PATH
and save

source .bashrc

Install Node Process Manager PM2

sudo npm install pm2@latest -g
cd ~
pm2 init
sudo nano ecosystem.config.js

Install Strapi on AWS EC2

https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment