I would like to have my new Rails project run on DockerToolbox.
The Rails version is 4.0.0.
#...set up abbreviated Docker Toolbox...
$ git clone path /to /repository.git project
$ cd project
# Install gem
$ bundle -- path vendor/bundle
# Start config
$ config up-d
# Migration performed (DB already created)
$ rakedb:migrate
The above rake task will fail.
The error details are as follows:
Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE installed:...
As per Note, if the MySQL version is 5.7.3 or later, MySQL appears to be causing an error due to the activerecord implementation.
So I tried to change the MySQL version to 5.6 series, but I can't do it well.
The Dockerfile of fig.yml and mysql is as follows.
fig.yml
mysql:
build:./docker/mysql
environment:
- MYSQL_ROOT_PASSWORD=password
volumes_from:
- data
ports:
- "3306:3306"
data:
image:centos:centos6
command: /bin/bash
volumes:
- /data
- /var/lib/mysql
docker/mysql/Dockerfile
FROM mysql:5.6
RUN cp-p/usr/share/zoneinfo/Asia/Tokyo/etc/localtime
ADD config /my.cnf /etc/my.cnf
This is what happens in this state.
$fig build
$ config up-d
$ figps
# =>Name Command State Ports
# =>----------------------------------------------------------------------------------------------------------------------
# =>app_data_1/bin/bash Exit 0
# =>app_mysql_1/entrypoint.sh mysqld Exit1
#
Here is the result of fig logs
.
mysql_1 | mkdir:cannot create directory ''': No such file or directory
I understand that here is an error, but I don't know what to do from now on.
ruby-on-rails mysql docker
Could you tell me the environment of the docker?
rakedb: I thought it might be possible to execute migration only in the container.
My execution environment uses boot2docker for docker-machine on OSX.In this environment, mysqld, which was guided by docker hub mysql, was launched as follows:
%docker run --name some-mysql-e MYSQL_ROOT_PASSWORD=my-secret-pw-d mysql:5.6
This mysqld shows the 3306/tcp port from the docker-machine virtual host (I am VirtualBox), and the 3306/tcp port is not visible on the terminal where this command was issued.
You may be able to run the rails application by placing it in a docker container.
%docker run-it --link some-mysql:mysql --rm your-rails-app-container'rakedb:create&rakedb:migrate&rails'
That's all.
580 PHP ssh2_scp_send fails to send files as intended
569 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
602 GDB gets version error when attempting to debug with the Presense SDK (IDE)
570 Who developed the "avformat-59.dll" that comes with FFmpeg?
902 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.