0% found this document useful (0 votes)
65 views4 pages

Docker Compose - Practice

Uploaded by

nilesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views4 pages

Docker Compose - Practice

Uploaded by

nilesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Docker compose

step 1: download docker compose.

Step 2: change permission to docker-compose file

Step 3: create directory and docker-compose.yml file

vi docker-compose.yml

version: "3"

services: #global value

database:

image: mysql:5.7

volumes:

- ./data:/var/lib/mysql

environment:

MYSQL_ROOT_PASSWORD: somewordpress

MYSQL_DATABASE: wordpress

MYSQL_USER: wordpress

MYSQL_PASSWORD: wordpress

wordpress:

image: wordpress

depends_on:

- database

ports:

- "8080:80"

restart: always

environment:

WORDPRESS_DB_HOST: database:3306

WORDPRESS_DB_USER: wordpress

WORDPRESS_DB_PASSWORD: wordpress

WORDPRESS_DB_NAME: wordpress
Step 4: Run docker compose file

docker-compose up -d

From compose file it will read and install an image and container

Use public id and port number to check results


Container Access through ssh protocol

# cd /root

# vi Dockerfile
FROM ubuntu:16.04

MAINTAINER Gayathri

RUN apt-get update

RUN apt-get install wget openssh-server -y

RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config

RUN echo 'root:root123' | chpasswd

RUN mkdir /var/run/sshd

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

EXPOSE 22
# Open new session in putty login with public ip and port forwarded number.

You might also like