0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

dockerをEC2で起動→dockerにログイン→dockerファイル作成→ビルド→プッシュまでやってみる

Last updated at Posted at 2021-12-07

OS
RHEL-7.7_HVM-20190923-x86_64-0-Hourly2-GP2

yum install yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
ls /etc/yum.repos.d/docker-ce.repo
yum list docker-ce --showduplicates | sort -r

有効化するとこうなる
# yum-config-manager --enable rhui-rhel-7-server-rhui-extras-rpms
# yum repolist all | grep extras
rhui-rhel-7-server-rhui-extras-debug-rpms/x86_64                  disabled
rhui-rhel-7-server-rhui-extras-rpms/x86_64                        enabled:  1,413
rhui-rhel-7-server-rhui-extras-source-rpms/x86_64                 disabled
※↑これをしないと有効化が必要なのでエラーになる
# yum install docker-ce-18.06.1.ce-3.el7
Loaded plugins: amazon-id, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:18.06.1.ce-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2.9 for package: docker-ce-18.06.1.ce-3.el7.x86_64
--> Finished Dependency Resolution
Error: Package: docker-ce-18.06.1.ce-3.el7.x86_64 (docker-ce-stable)
           Requires: container-selinux >= 2.9
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
yum install docker-ce-18.06.1.ce-3.el7
docker --version
systemctl status docker
systemctl start docker
getent group | grep docker
docker run hello-world

aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.comdocker 
sudo vi Dockerfile

/Dockerfile

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
docker build -t hello-world .
docker images --filter reference=hello-world
docker tag hello-world:latest aws_account_id.dkr.ecr.region.amazonaws.com/hello-world:latest
docker push aws_account_id.dkr.ecr.region.amazonaws.com/hello-world:latest

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?