Search code examples
mysqllinuxubuntuboot2docker

Docker cannot start container no such file or directory


I'm unable to start my container after build and I got :

Error response from daemon: Cannot start container ogc-mysql: no such file or directory
Error: failed to start one or more containers

Here is my Docker file :

FROM ubuntu:latest

MAINTAINER Davin Kevin

# Install latest updates
RUN apt-get update
RUN apt-get upgrade -y

# Install mysql client and server
RUN apt-get -y install mysql-client mysql-server curl

# Enable remote access (default is localhost only, we change this
# otherwise our database would not be reachable from outside the container)
RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf

# Install database
ADD ./database.sql /var/db/database.sql

# Set Standard settings
ENV user ogc
ENV password ogc
ENV url file:/var/db/database.sql
ENV right READ

# Install starting script
ADD ./start-database.sh /usr/local/bin/start-database.sh
RUN chmod +x /usr/local/bin/start-database.sh

EXPOSE 3306

CMD ["/usr/local/bin/start-database.sh"]

And my sh script only does :

docker build -t ogc-mysql .
docker run --name ogc-mysql -d -p 3306:3306 ogc-mysql

And reffering to the Docker documentation :

docker build will return a no such file or directory error if the file or directory does not exist in the uploaded context. This may happen if there is no context, or if you specify a file that is elsewhere on the Host system. The context is limited to the current directory (and its children) for security reasons, and to ensure repeatable builds on remote Docker hosts. This is also the reason why ADD ../file will not work.

This command : docker ps -a returns :

CONTAINER ID : 70..
IMAGE : ogc-sql:latest
COMMAND : "/usr/local/bin/star"
CREATED : 13 seconds ago
STATUS : /
PORTS : /
NAMES : ogc-mysql

The fact is that this command works successfully on Mac OS..


Solution

  • Problem solved, it was a line-ending problem in the sh files...