0

I want to enable ssh to existing docker container which consists of custom wordpress application ,at the end i have to deploy that image to aws ecs fargate

This my complete docker setup for db i m using rds

Docker-compose.yml

version: '3'
services:
  wordpress:
    build: .
    restart: always
    ports:
      - "80:80"
    environment:
      WORDPRESS_DB_HOST: <rdshost>
      WORDPRESS_DB_USER: <user>
      WORDPRESS_DB_PASSWORD: <>
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_CONFIG_EXTRA: |
   
    volumes:
     - wordpress:/var/www/html
  # phpmyadmin:
  #   image: phpmyadmin/phpmyadmin
  #   container_name: pma-23456
  #   links:
  #     - db
  #   environment:
  #     PMA_HOST: db
  #     PMA_PORT: 3306
  #     PMA_ARBITRARY: 1
  #   restart: always
  #   ports:
  #     - 8089:80      
  # db:
  #   image: mysql:5.6.40
  #   restart: always
  #   logging:
  #     driver: none
  #   environment:
  #     MYSQL_ROOT_PASSWORD: root
  #     MYSQL_USERNAME: root
  #     MYSQL_PASSWORD: root
  #     MYSQL_DATABASE: sdewebsite
  #   volumes:
  #     - db:/var/lib/mysql
  #   ports:
  #     - "33062:3306"
volumes:
  wordpress:
  # db:

DOCKERFILE

FROM php:5.6-apache
RUN apt-get update && apt-get install -y cron git-core vim \
  libjpeg-dev libmcrypt-dev libpng-dev libpq-dev libsqlite3-dev && \
  rm -rf /var/lib/apt/lists/* && \
  docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr && \
  docker-php-ext-install gd mysqli opcache mysql pdo pdo_mysql zip
# Install the mysqli extension
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install mysql
COPY ["html","/var/www/html/"]
RUN chown -R www-data:www-data  /var/www/html/*
COPY ./config/uploads.ini /usr/local/etc/php/conf.d/uploads.ini

CMD ["/usr/sbin/sshd","-D"]

The result should be a docker image that has ssh enabled that can be accessed through aws as well as locally

ps:i m using windows

  • Does this help? https://stackoverflow.com/questions/28134239/how-to-ssh-into-docker – Andy Preston Apr 24 '23 at 23:02
  • ssh uses port 22. You only have port 80 mapped to the container, so there is the start of your problem. With fargate it is much more complex: See https://medium.com/ci-t/9-steps-to-ssh-into-an-aws-fargate-managed-container-46c1d5f834e2 – gview Apr 24 '23 at 23:23
  • You must install OpenSSH Server into your container and then configure SSH keypairs and/or users and passwords. Then you must configure/start multiple services on container start. Think twice before doing that. Containers should be small, secure and only contain the required software and no more. If your goal is to debug or configure a container, using SSH is not the correct approach. Debug locally and use logging for production. In the cloud, most container services will **not support** running your container. – John Hanley Apr 25 '23 at 00:11

0 Answers0