Docker Community Forums

Share and learn in the Docker community.

Parse Error when attempting to build app


(Sgodfrey81) #1

I’m following the Tutorial but on Stage 2 for containers I’m getting a parse error when running the build command.

Error, “Error response from daemon: Dockerfile parse error line 1: unknown instruction: {\RTF1\ANSI\ANSICPG1252\COCOARTF1404\COCOASUBRTF470”

I’ve removed the extension from the docker file and checked all other files so I can’t work this out.

A bit embarrassing failing at virtually the first hurdle! :frowning:


(Sgodfrey81) #2

Any suggestions? I’ve recreated the dockerfile, tried on a different laptop and still get the same error :frowning:


(Sam) #3

sorry, what tutorial, only a couple hundred out there…


(Sgodfrey81) #4

Fair comment. This one: https://docs.docker.com/get-started/part2/


(Sam) #5

please show your Dockerfile


(Sam) #6

i just did the tutorial without problem

create a folder
make folder current directory
create three files
issue docker build
issue docker run


(Sgodfrey81) #7
# Use an official Python runtime as a parent image
FROM python:2.7-slim

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World

# Run app.py when the container launches
CMD ["python", "app.py"]

(Sam) #8

and requirements.txt
and app.py


(Sgodfrey81) #9
from flask import Flask
from redis import Redis, RedisError
import os
import socket

# Connect to Redis
redis = Redis(host="redis", db=0, socket_connect_timeout=2, socket_timeout=2)

app = Flask(__name__)

@app.route("/")
def hello():
    try:
        visits = redis.incr("counter")
    except RedisError:
        visits = "<i>cannot connect to Redis, counter disabled</i>"

    html = "<h3>Hello {name}!</h3>" \
           "<b>Hostname:</b> {hostname}<br/>" \
           "<b>Visits:</b> {visits}"
    return html.format(name=os.getenv("NAME", "world"), hostname=socket.gethostname(), visits=visits)

if __name__ == "__main__":
    app.run(host='0.0.0.0', port=80)

Flask
Redis


(Sgodfrey81) #10

Resolved this by editing Dockerfile in Atom.