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:

(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

# 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 -r requirements.txt

# Make port 80 available to the world outside this container

# Define environment variable

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

(Sam) #8

and requirements.txt

(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__)

def hello():
        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__":'', port=80)


(Sgodfrey81) #10

Resolved this by editing Dockerfile in Atom.