Chris G.
Chris G.

Reputation: 25964

executing a command in Dockerfile not working

Dockerfile:

FROM golang:latest

# COPY  kube/command.sh .
RUN apt-get update

# To be able to do go run !(*_test).go
RUN apt-get install dnsutils  -y

# CMD [ "shopt -s extglob" ]
CMD [ "sh command.sh" ]
# RUN bash -c shopt -s extglob
# RUN "sh command.sh"    

Also tried with a script file(command.sh):

#!/bin/sh

shopt -s extglob

And RUN bash -c shopt -s extglob

Building Dockerfile I get this:

bash: !: event not found

If I run the container and manually doing shopt -s extglob: it works.

Do you know why?

Upvotes: 1

Views: 1591

Answers (1)

Truong Dang
Truong Dang

Reputation: 3417

Try this may help:

FROM golang:latest


RUN apt-get update

# To be able to do go run !(*_test).go
RUN apt-get install dnsutils  -y
# COPY  kube/command.sh .
COPY commands.sh /scripts/commands.sh
RUN ["chmod", "+x", "/scripts/commands.sh"]
ENTRYPOINT ["/scripts/commands.sh"]

Upvotes: 1

Related Questions