Docker Run Static Website

Deploy A Static Website with Docker The static websites are the HTML pages, directly severed by any web servers. It may also include some other static assets like css, js and images. In this tutorial you will learn, how to deploy a static website on Docker container. 1. Create A Static Website We assume you already have a static site on your system. For this tutorial, I have downloaded a static website from here. After making some changes, placed all files in a directory on Docker server. 2. Create Dockerfile…

Read More

Docker Java Example

Run Java Application with Docker Docker provides official images to run Java program on command line. You can run Java programs without installing Java on your system. This will be helpful to you choose any version of Java during program execution. This tutorial will help you to run a sample java program using Docker containers. Run Java Program with Docker The below steps will help you to create a sample Java program. then create a Dockerfile to run a Java program under the docker container. After that build a custom…

Read More

Docker Python Example

Run Python Application with Docker You can run a Python script using Docker containers. This tutorial will help you to run a Python script over command line within Docker isolated environment. Run Python Example within Docker Create Python Script – First, create a sample Python script to run on web server under the Docker container. Edit script.py in your favorite text editor. nano script.py Add the following content:

Create Dockerfile – Next create a file named Dockerfile under the same directory. Edit Dockerfile in a text editor: nano Dockerfile…

Read More

Docker PHP CLI Example

Run PHP CLI Application with Docker Docker provides official images to run PHP script on command line. These are helpful to run script on shell, scheduled jobs with php script like cron jobs. This tutorial will help you to run a sample php script on CLI using Docker containers. Run PHP CLI on Docker The CLI scripts run on a terminal, these scripts are helpful to background jobs, scheduled jobs with the crontab. The below example, will run a sample php script with CLI on Docker. Create PHP Script –…

Read More

Docker PHP Example

Run PHP Web Application with Docker You can run any PHP application on using web server or command line using Docker containers. This tutorial will help you to run a PHP script over command line with a Docker container. Also, you will find the instructions to run a PHP script over Apache/Nginx web server with Docker. Docker PHP Example with Apache Create PHP Script – First, create a sample PHP script to run on web server under the Docker container. Edit index.php in your favorite text editor. nano index.php Add…

Read More

Docker – cp

Docker cp command Docker cp command is used to copy files between docker host system and container machine. This will work even the docker container is not running. Syntax: docker cp [OPTIONS] SRC_PATH DEST_PATH Copy File from Container to Host Copy a file /opt/testfile.txt from container id 043869c58300 to host machine /tmp directory. use following example. $ docker cp 043869c58300:/opt/testfile.txt /tmp You can also use container name instead of container ID. Copy File from Host to Container Also, copy a file /opt/newfile.txt from host system to container ( id 043869c58300)…

Read More

Docker – run

Docker run command Use Docker run command to launch containers from an image. It provides a large number of options. Syntax docker run [OPTIONS] IMAGE [COMMAND] [ARG…] Example For example, run the hello-world example officially provided by Docker community to test your installation. Run command will also download the image from docker hub it not found locally. $ sudo docker run hello-world As a better use, you can use -i to keep STDIN open and -t to allocate a TTY to the container. You can also use -d to run…

Read More

Docker – ps

Docker ps command Use ps command to list the docker containers on your local system. Syntax docker ps [OPTIONS] Example To list all running container use the following command. $ docker ps Docker ps Options #1. List All (-a, –all) Use this switch to show all containers created on local system, either they are in any state. $ docker ps -a #2. Show ID Only (-q, –quiet) This option will only display the numeric id only of the container. $ docker ps -q #3. Show Size (-s, –size) This option…

Read More

Docker – build

Docker build command Docker build command is used to build an image from a Dockerfile. For more details visit our Dockerfile and Dockerfile directives tutorial. Syntax docker build [OPTIONS] [Dockerfile PATH|URL] Example Let’s create an example Dockerfile in your current directory. vim Dockerfile and add the following content.

Now build the image using single dot “.”, as Dockerfile is available in the current directory. Also, use -t image_name to specify tag name to the image. docker build -t apache_ubuntu . The build command will pull the image “tecadmin/ubuntu-ssh:16.04” from…

Read More

Docker – Compose Example

Docker Compose Example This is the step by step tutorial to understand uses of Docker compose. In this tutorial, I will create two Docker containers using Docker compose. One docker container will have MySQL database instance and another Docker container have Apache web server with our dummy application file. Let’s follow step by step tutorial and watch the things happening there. Step 1 – Create Directory Structure First of all, create a directory structure. Here webapp is our web application directory. Also, create a index.html in webapp directory for testing.…

Read More