Your First Dockerfile(SCA-cloud test)

A few weeks ago, She Code Africa called for applications for its cloud internship. One of the technical assessments was on Docker containers. You can look up the assessment here. Was the test too challenging for you? well, it’s not too late to learn now.

Basically, the whole idea is to run an application from a Docker container. Just like running an app on localhost but this time it’s on Docker environment. Our preferred language is JavaScript and we will be running a Nodejs application from a docker container.

Okay, let’s start.

  • A GitHub account
  • An account with Docker hub at
  • Download and set up your Docker desktop.
  • Nodejs Command line tool installed.
  • Create a repository named SCA Cloud School Application on your GitHub account. Remember to add a readme file.
  • Clone the repository to your terminal. You are currently on the master(main) branch.

Switch to a branch stable git checkout -b stable and create a folder called docker.

  • Run npm init (App name: docker-sample, Entry point: app.js)
  • Run npm install express
This is what your package.json file should look like.

Note: Replace script object

“scripts”: { 
“test”: “echo \”Error: no test specified\” && exit 1"


“scripts”: {“start”: “node app.js”

Your file structure

| — — node_modules
| — — views
| | — — index.html
| — — .dockerignore
|— — .gitignore
| — App.js
| — — Dockerfile
|— — package-lock.json
|— — package.json


index.html (inside views folder.)

  • On the terminal Runnpm start. you should have your server running on port 8080. Go the http://localhost:8080 to view the message Welcome to SCA Cloud School Application

Add these codes to your Dockerfile

  • Add
    to the .dockerignore file, to prevent the files from being copied to the docker image during build. .dockerignore is similar to .gitignore.

Run docker build -t dockerdemo where dockerdemo is the name of your image. Run docker run -p 4990:8080 -d dockerdemo

  • Go to your docker desktop to view and run the docker image .
  • Your docker image should be running on http://localhost:49160 . To view images in your container Run docker images
  • Remember, you are on the stable branch.
  • Rungit add .and git commit -m "message" and git push to push the docker folder to the SCA-GitHub repository created.
  • Create a repo in Docker Hub named sca-cloud-docker.
  • Run docker tag image-id yourhubusername/reponame:tag — example: docker tag 9c9f09c6e82e yourhubusername/sca-cloud-docker:stable
  • Run docker push yourhubusername/reponame:tag — example: docker push yourhubusername/sca-cloud-docker:stable
  • Check out to feature branch git checkout -b feature
  • Change the content of the index.html file to “Welcome to SCA Cloud School Application, this is my first assessment”
  • Build and run a docker image docker build -t docker-feature ,docker run -p 4990:8080 -d docker-feature n/b: we use a different port number
  • Run your generated image on the docker desktop, confirm on http://localhost:4990
  • Add, commit and push feature branch to GitHub.
  • Push to the same docker repository docker tag image-id:yourhubusername/reponame:tag , docker push yourhubusername/reponame:tag n/b: we use feature as a tag.

Other things to note based on instruction:

  • Merge feature branch to stable and do not delete the feature branch.
  • The master branch should have only a read-me file with documentation.

That is it…✌ You can view the repo here

I hope this really helped someone. I appreciate comments and questions where you don’t understand. BYE!

Software developer. Imaginative. I love daring and exploring. The confusion in startups is thrilling and i love it.