如何在aws上部署使用版本2创建的docker镜像

时间:2018-04-23 10:45:39

标签: amazon-web-services docker amazon-ec2

我是码头工人的新手。我以某种方式用版本2 docker compose创建了docker项目以下是我的docker-compose.yml

version: "2"

services:
  # Configuration for php web server
  webserver:
    image: inshastri/laravel-adminpanel:latest
    restart: always
    ports:
      - '8080:80'
    networks: 
      - web
    volumes:
      - ./:/var/www/html
      - ./apache.conf:/etc/apache2/sites-available/000-default.conf
    depends_on: 
      - db
    links:
      - db
      # - redis
    environment:
      DB_HOST: db
      DB_DATABASE: phpapp
      DB_USERNAME: root
      DB_PASSWORD: toor
  # Configuration for mysql db server
  db:
    image: "mysql:5"
    volumes:
      - ./mysql:/etc/mysql/conf.d
    environment:
      MYSQL_ROOT_PASSWORD: toor
      MYSQL_DATABASE: phpapp
    networks: 
      - web
    restart: always
  # Configuration for phpmyadmin (optional) 
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    environment:
      PMA_PORT: 3306
      PMA_HOST: db
      PMA_USER: root
      PMA_PASSWORD: toor
    ports:
    - "8004:80"
    restart: always
    depends_on: 
    - db
    networks: 
    - web
  redis:
    image: redis:4.0-alpine
   # Network connecting the whole app 
networks: 
    web:
      driver: bridge

并使用如下的docker文件

FROM ubuntu:16.04

RUN apt-get update \
    && apt-get install -qy language-pack-en-base \
    && locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8

RUN  apt-get -y install apache2
RUN  a2enmod headers 
RUN  a2enmod rewrite






# add PPA for PHP 7
    RUN apt-get install -y --no-install-recommends apt-utils
    RUN apt-get install -y software-properties-common python-software-properties
    RUN add-apt-repository -y ppa:ondrej/php

#  Adding php 7

RUN  apt-get update 
RUN  apt-get install -y php7.1 php7.1-fpm php7.1-cli php7.1-common php7.1-mbstring php7.1-gd php7.1-intl php7.1-xml php7.1-mysql php7.1-mcrypt php7.1-zip  
RUN  apt-get -y install libapache2-mod-php7.1 php7.1 php7.1-cli php-xdebug php7.1-mbstring sqlite3 php7.1-mysql php-imagick php-memcached php-pear curl imagemagick php7.1-dev php7.1-phpdbg php7.1-gd npm nodejs-legacy php7.1-json php7.1-curl php7.1-sqlite3 php7.1-intl apache2 vim git-core wget libsasl2-dev libssl-dev 

RUN apt-get -y install libsslcommon2-dev libcurl4-openssl-dev autoconf g++ make openssl libssl-dev libcurl4-openssl-dev pkg-config libsasl2-dev libpcre3-dev 

RUN  apt-get install -y imagemagick graphicsmagick  
RUN  a2enmod headers 
RUN  a2enmod rewrite



ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
ENV APACHE_RUN_DIR /var/run/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
    ln -sf /dev/stderr /var/log/apache2/error.log
RUN mkdir -p $APACHE_RUN_DIR $APACHE_LOCK_DIR $APACHE_LOG_DIR


# Update application repository list and install the Redis server. 
RUN apt-get update && apt-get install -y redis-server




# Allow Composer to be run as root
ENV COMPOSER_ALLOW_SUPERUSER 1

# Setup the Composer installer
RUN curl -o /tmp/composer-setup.php https://getcomposer.org/installer \
    && curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig \
    && php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" \
    && php /tmp/composer-setup.php \
    && chmod a+x composer.phar \
    && mv composer.phar /usr/local/bin/composer

# Install composer dependencies
RUN echo pwd: `pwd` && echo ls: `ls` 

# RUN composer install


EXPOSE 80

# Expose default port
EXPOSE 6379



VOLUME [ "/var/www/html" ,"./mysql:/etc/mysql/conf.d",]
WORKDIR /var/www/html


ENTRYPOINT [ "/usr/sbin/apache2" ]
CMD ["-D", "FOREGROUND"]

COPY . /var/www/html
COPY ./apache.conf /etc/apache2/sites-available/000-default.conf

现在有很多东西在google搜索后无法理解 1)当我将图像提供给我的朋友时,他接受了拉动,当他运行时,它没有其他服务,如mysql和phpmyadmin

2)我应该如何将此应用程序部署到ec2 amazon

有许多东西但是无法理解它们中的任何一种,比如ec2 beanstalk等 请指导一个简单的上传我的图像文件到aws并运行它也如何我在我的朋友的电脑上运行我的图像,因为我的码头是一个集装箱管理系统它应该得到我的所有服务,就像我的朋友或任何人采取拉我的形象

对于我的形象是inshastri / laravel-adminpanel

请提前帮助

0 个答案:

没有答案