[AWS] Lab: Docker and CodeCommit Part 1
2023-09-14 08:59:12 时间
Overview
Create IAM User with CodeCommit Access
Configure local AWS user
aws configure
HTTPS Git credentials for AWS CodeCommit
Create CodeCommit Repo
- Clone the Repo by using HTTPS
- Copy Dockerfile and buildspec.yml to your local repo
Dockerfile
FROM ubuntu:12.04 # Install dependencies RUN apt-get update -y RUN apt-get install -y apache2 # Install apache and write hello world message RUN echo "Helloo Cloud Gurus!!!! This web page is running in a Docker container!" > /var/www/index.html # Configure apache RUN a2enmod rewrite RUN chown -R www-data:www-data /var/www ENV APACHE_RUN_USER www-data ENV APACHE_RUN_GROUP www-data ENV APACHE_LOG_DIR /var/log/apache2 EXPOSE 80 CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
buildspec.yml
version: 0.2 #env: #variables: # key: "value" # key: "value" #parameter-store: # key: "value" # key: "value" phases: install: commands: - nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2& - timeout 15 sh -c "until docker info; do echo .; sleep 1; done" pre_build: commands: - echo Logging in to Amazon ECR.... - aws --version # update the following line with your own region - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin xxxx.dkr.ecr.us-east-1.amazonaws.com build: commands: - echo Build started on `date` - echo Building the Dockeroo image... # update the following line with the name of your own ECR repository - docker build -t mydockerrepo . # update the following line with the URI of your own ECR repository (view the Push Commands in the console) - docker tag mydockerrepo:latest xxxx.dkr.ecr.us-east-1.amazonaws.com/mydockerrepo:latest post_build: commands: - echo Build completed on `date` - echo pushing to repo # update the following line with the URI of your own ECR repository - docker push xxxx.dkr.ecr.us-east-1.amazonaws.com/mydockerrepo:latest #artifacts: # - location # - location #discard-paths: yes #base-directory: location #cache: #paths: # - paths
- Push files to remote CodeCommit repo
Next, we are going to create a Elastic Container Service to able to run our Docker image.
Create ECS
Once it successed, you should be able to see your cluster:
Create Repositories
- Give a name for your repo, for example: `mydockerrepo`
- Click button "View Push Commands"
When you run the first command, you will get Auth Error, what you need to is add permission to your created user
Add Permisson for User
- Run the "View Push Commands" again, you will see "Login Successed"
- Build Docker image
- Tag Docker image
- Push Docker image
- Click "Copy URI" in last image, we need to use it later
Launch Docker Container
- Go to Task Definitions
- Give a name `mytaskdef`
- Click "Add Container"
- "image" is the URI that we just copy
- Create a Service
- Launch Type should be "EC2"
- Service name: "myservice"
- Number of tasks: 1
- Rest should be default
You should see service has reached a stead state
- Go back to "Cluster" -> "myCluster" -> "EC2 instance" -> Copy "IPV4 public address" -> Open in Broswer
相关文章
- docker 权限问题 Got permission denied while trying to connect to the Docker daemon socket at 。。。「建议收藏」
- AWS工程师辞职创建Tensor Search引擎,即插即用HuggingFace版CLIP模型
- docker 离线安装_Docker安装
- Docker安装docker-compose插件
- Docker服务的重启服务命令(systemctl restart docker)
- Docker高级篇:docker网络的四种类型
- 如何使用YATAS审查AWS基础设施中潜在的安全问题
- AWS简单搭建使用EKS一
- 【Docker 系列】docker 学习 二,Docker 的常用命令
- 【Docker 系列】docker 学习十,Compose 编写规则及wp 实战
- 芯片创新如何成为AWS成功背后的 "秘诀"
- MySQL Error number: MY-011430; Symbol: ER_KEYRING_AWS_INVALID_KEY_LENGTH_FOR_CIPHER; SQLSTATE: HY000 报错 故障修复 远程处理
- MySQL Error number: MY-011437; Symbol: ER_KEYRING_AWS_FAILED_TO_CONNECT_KMS; SQLSTATE: HY000 报错 故障修复 远程处理
- Docker容器的重启策略及docker run的–restart选项详解程序员
- Linux下Docker安装指南(linux下docker安装)
- 亚马逊AWS推出专门面向量子计算的新博客频道
- 商标侵权败诉后亚马逊在中国启用新名称亚马逊云科技放弃AWS标志
- 如何在Amazon AWS上创建S3存储桶(对象存储)
- AWS 采用自制的 KVM 作为新的管理程序
- AWS 帮助构建 ONNX 开源 AI 平台
- 头号玩家AWS意外落败!微软获100亿美元云服务超级大单
- 上万个公司都在用的机器学习服务SageMaker,AWS宣布要在中国推出了
- 亚马逊云服务AWS崩了?一众互联网公司挂了!
- Apple的MacOS首次出现在云端,AWS EC2实例迎来大更新
- AWS上如何安装MySQL?(awsmysql安装)
- 亚马逊AWS机器学习总监Alex Smola:如何用MXNet构建可拓展的深度学习框架?|AAAI 2017
- 使用AWS同步构建MySQL数据库环境(aws同步mysql)
- 在AWS上搭建MySQL数据库系统的中文化指南(aws mysql 中文)
- 云上极致AWS支持Oracle创造无限可能(aws支持oracle)
- 探索Docker安装Oracle数据库的秘密(docker安装oracle)