-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathbuild_docker_image reference.sh
More file actions
33 lines (23 loc) · 1023 Bytes
/
build_docker_image reference.sh
File metadata and controls
33 lines (23 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# create a repository to store the docker image in docker hub
# launch an ec2 instance. open port 80 and port 22
# install and configure docker on the ec2 instance
sudo yum update -y
sudo amazon-linux-extras install docker -y
sudo service docker start
sudo systemctl enable docker
# create a dockerfile
# build the docker image
sudo docker build -t <image-tag> .
# login to your docker hub account
cat ~/my_password.txt | sudo docker login --username <your-docker-id> --password-stdin
# use the docker tag command to give the image a new name
sudo docker tag <image-tag> <repository-name>
# push the image to your docker hub repository
sudo docker push <repository-name>
# start the container to test the image
sudo docker run -dp 80:80 <repository-name>
# referances
# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-container-image.html
# https://docs.docker.com/get-started/02_our_app/
# https://docs.docker.com/engine/reference/commandline/login/#provide-a-password-using-stdin