HowTo:Docker: Difference between revisions

From Computer Science Wiki
Jump to navigation Jump to search
(Created page with "== Introduction == This guide will walk you through creating a git repository which gives you a docker registry to host docker images, build a docker image, and push the image up to the registry. The image will be based on the official PHP docker image https://hub.docker.com/_/php , and a copy of ''Chatbot for College Students'' app installed https://github.com/AaravRajSIngh/Chatbot You will need access to workstation that has Docker installed. You can SSH to rlogin....")
 
No edit summary
Line 32: Line 32:


# Install additional PHP modules
# Install additional PHP modules
RUN docker-php-ext-install mysqli mysqlnd pdo pdo_mysql zip
RUN docker-php-ext-install mysqli pdo pdo_mysql


# Download chatbot app
# Download chatbot app
cd /var/www/html && git clone https://github.com/AaravRajSIngh/Chatbot.git .
RUN cd /var/www/html && \
    git clone https://github.com/AaravRajSIngh/Chatbot.git . && \
    chmod 600 .git
</pre>
</pre>

Revision as of 14:41, 6 November 2023

Introduction

This guide will walk you through creating a git repository which gives you a docker registry to host docker images, build a docker image, and push the image up to the registry. The image will be based on the official PHP docker image https://hub.docker.com/_/php , and a copy of Chatbot for College Students app installed https://github.com/AaravRajSIngh/Chatbot You will need access to workstation that has Docker installed. You can SSH to rlogin.cs.vt.edu and build docker images there. This example compliments the CS Launch walkthrough at HowTo:CS Launch which will walk you through hosting this docker image using Computer Science kubernetes cluster.

Create Repository

Computer offers two Gitlab instances: https://git.cs.vt.edu and https://version.cs.vt.edu git.cs.vt.edu is geared toward academic use, and version.cs.vt.edu is for departmental or research use. We will use git.cs.vt.edu for this example.

  • Log into https://git.cs.vt.edu using your CS username and password.
  • Click on Projects from the menu on the left.
  • Click on the New Project button.
  • Click on the Create blank project tile.
  • Fill in Project name field with a unique name for your docker image project. Example: chatbot
  • Fill in Project URL fields with your own sub path and project slug.
  • Select Visibility Level If your project is public then anyone on the Internet will be able to download and use your docker image given the correct URL. If your project is Private or Internal then to use your docker image you need to create and use a deployment token which will be discussed further in this walk through.
  • Click on the Create project button.
  • A docker image registry is automatically created with your git repository.
  • Adding files to this git repository is optional, however you might find it a useful place to store versioned copies of your Docker image creation files.

Create Docker Image

  • SSH to rlogin.cs.vt.edu See Howto::Access_rlogin_service Alternatively, you can use any workstation that has Docker installed.
  • Optional: Clone your git repository.
  • Use a text editor to create a new file called Dockerfile
    • Example: nano Dockerfile
    • Contents:
# Start from Apache based PHP image
FROM php:apache

# Make sure git command is installed
RUN apt-get update && \
    apt-get install vim git -y

# Install additional PHP modules
RUN docker-php-ext-install mysqli pdo pdo_mysql

# Download chatbot app
RUN cd /var/www/html && \
    git clone https://github.com/AaravRajSIngh/Chatbot.git . && \
    chmod 600 .git