Skip to content

Instantly share code, notes, and snippets.

@ogre-yoga
Last active November 11, 2024 11:47
Show Gist options
  • Select an option

  • Save ogre-yoga/04c6cc817e9f95ee788b3893db93fa3a to your computer and use it in GitHub Desktop.

Select an option

Save ogre-yoga/04c6cc817e9f95ee788b3893db93fa3a to your computer and use it in GitHub Desktop.
Pull and run Docker image on Amazon Linux EC2 instance

Pull and run docker image on Amazon Linux EC2 instance

Install and run Docker service

  1. SSH in $ ssh -i [PRIVATE_KEY.PEM] ec2-user@[EC2_DNS_HOSTNAME]
  2. Update OS and packages $ sudo yum update
  3. Install Docker $ sudo yum install -y docker
  4. Start Docker $ sudo service docker start

Pull docker image

  1. Log in to registry $ sudo docker login --username [USERNAME] $ password: [PASSWORD]
  2. Pull the required image $ sudo docker pull [USERNAME]/[IMAGE]:[TAG]

Run container with image

  1. View local docker images $ sudo docker images
  2. Run docker container with image $ sudo docker run -p [CONTAINER_PORTS] [IMAGE_ID] e.g. $ sudo docker run -p 5001:5001/tcp a1b2c3d4 (Docker docs -p flag)
  3. View local containers $ sudo docker ps
  4. Stop docker container $ sudo docker stop [CONTAINER_ID]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment