简体   繁体   中英

export command in Dockerfile giving error in Docker build

For the following dockerfile

FROM ubuntu:20.04
COPY apache-cassandra-3.11.6-bin.tar.gz .
RUN tar -xzf apache-cassandra-3.11.6-bin.tar.gz 
RUN ls
RUN echo $PATH
RUN pwd
RUN export CASSANDRA_HOME = /apache-cassandra-3.11.6
RUN export PATH = $PATH:$CASSANDRA_HOME/bin
RUN echo $PATH
RUN ls
WORKDIR apache-cassandra-3.11.6/bin
RUN ls
CMD ["cassandra","-f"]

I am getting error

/bin/sh: 1: export: : bad variable name
The command '/bin/sh -c export CASSANDRA_HOME = /apache-cassandra-3.11.6' returned a non-zero code: 2

Why?

The full output is

C:\Users\manuc\Documents\manu\cassandra_image_test>docker build -f CassandraImageDockerFile.txt -t manucassandra .
Sending build context to Docker daemon  184.8MB
Step 1/13 : FROM ubuntu:20.04
 ---> 74435f89ab78
Step 2/13 : COPY apache-cassandra-3.11.6-bin.tar.gz .
 ---> Using cache
 ---> caa6b38eaee8
Step 3/13 : RUN tar -xzf apache-cassandra-3.11.6-bin.tar.gz
 ---> Using cache
 ---> f05803d3b504
Step 4/13 : RUN ls
 ---> Running in a4c1eba27e03
apache-cassandra-3.11.6
apache-cassandra-3.11.6-bin.tar.gz
bin
boot
dev
etc
home
lib
lib32
lib64
libx32
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var
Removing intermediate container a4c1eba27e03
 ---> b0734ff6ee6d
Step 5/13 : RUN echo $PATH
 ---> Running in 0e001fd39c0b
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Removing intermediate container 0e001fd39c0b
 ---> dd41966e8b65
Step 6/13 : RUN pwd
 ---> Running in 7f5a3ff2952e
/
Removing intermediate container 7f5a3ff2952e
 ---> 614449c7e7b9
Step 7/13 : RUN export CASSANDRA_HOME = /apache-cassandra-3.11.6
 ---> Running in ba11d2594acd
/bin/sh: 1: export: : bad variable name
The command '/bin/sh -c export CASSANDRA_HOME = /apache-cassandra-3.11.6' returned a non-zero code: 2

C:\Users\manuc\Documents\manu\cassandra_image_test>

It seems like a parsing error, /bin/sh: 1: export: : bad variable name . It didn't even try to export your variable. Have you tried simply removing the whitespaces and see if it works?

RUN export CASSANDRA_HOME=/apache-cassandra-3.11.6

RUN export PATH=$PATH:$CASSANDRA_HOME/bin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM