-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateDockerFile.json
More file actions
60 lines (38 loc) · 1.68 KB
/
CreateDockerFile.json
File metadata and controls
60 lines (38 loc) · 1.68 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
## Install and run docker
## Create docker file
touch Dockerfile
## Add below contents
"FROM ubuntu:18.04
# Install dependencies
RUN apt-get update && \
apt-get -y install apache2
# Install apache and write hello world message
RUN echo 'Hello World!' > /var/www/html/index.html
# Configure apache
RUN echo '. /etc/apache2/envvars' > /root/run_apache.sh && \
echo 'mkdir -p /var/run/apache2' >> /root/run_apache.sh && \
echo 'mkdir -p /var/lock/apache2' >> /root/run_apache.sh && \
echo '/usr/sbin/apache2 -D FOREGROUND' >> /root/run_apache.sh && \
chmod 755 /root/run_apache.sh
EXPOSE 80
CMD /root/run_apache.sh"
## cd to folder where above is kept
## build docker image
docker build -t hello-world .
## Run docker image
docker images --filter reference=hello-world
##Run the newly built image. The -p 80:80 option maps the exposed port 80 on the container to port 80 on the host system.
docker run -t -i -p 80:80 hello-world
##If you are running Docker locally, point your browser to http://localhost/.
## Authenticate to your default registry
## New system new - Access Key and Secrete for AWS CLI login
## Create you ecr repo
aws ecr create-repository --repository-name hello-world --region us-east-1
## Authenticate your docker to ecr == > gives encrypted password for docker
aws ecr get-login-password --region us-east-1
## Final Authenticate to ecr
aws ecr --region us-east-1 | docker login -u AWS -p <Above encrytped password> 357171621133.dkr.ecr.us-east-1.amazonaws.com/hello-world
## docker tag
docker tag hello-world:latest 357171621133.dkr.ecr.us-east-1.amazonaws.com/hello-world:latest
## docker push
docker push 357171621133.dkr.ecr.us-east-1.amazonaws.com/hello-world:latest