Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create application directory:

    • Begin by creating a dedicated directory for the application. This Directory will contain both the app and Dockerfile.

  2. Create an empty Docker file:

    • In this directory, create an empty Dockerfile using a text/code editor.

      Code Block
      sudo nano Dockerfile
  3. Add instruction to the Dockerfile:

    • Define the steps for building the Docker image in the Dockerfile. For example:

      Code Block
      #Set parent image 
      FROM ubuntu:22.04 as build 
      
      #Set working directory in the container 
      WORKDIR /app
      
      #Copy the local scripts and file to the container 
      COPY lyrics.sh .
      
      # Install any needed packages 
      RUN apt-get update && apt-get install -y \
          curl && \
          apt-get clean   
          
      #Make scripts executable and run the script
      RUN chmod +x lyrics.sh && ./lyrics.sh
  4. Build and Tag Docker image:

    • Build the Docker image in the same directory (“.”) as the Dockerfile. Tagging the image helps organize it, especially if you plan to push it to a Docker repository. Use meaningful names or version numbers as tags.

      Code Block
      docker build -t imagename:youtag .
      docker tag imagename:youtag imagename:image1
  5. Log into docker account and push image to docker repository

    • Log into docker account:

      Code Block
      docker login
    • Push image to a docker repo/registry. This will make it accessible to others:

      Code Block
      docker push tagname