Welcome Guest, Not a member yet? Register   Sign In
I cannot be executed migrate via Docker.
#1
Wink 

## premise
I understand basic of codeigniter4 via Docker.
[Image: 133973466-8cc59a05-cd08-4a0d-a76d-088e78dfd052.png]

## docker-compose.yml
```
version: "3"

services:
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
# C O D E I G N I T E R v4.1.4 #
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
codeigniter4:
image: atsanna/codeigniter4:latest
container_name: 'codeigniter4'
ports:
- 80:80
links:
- codeigniter4_mysql
volumes:
- ./localfolder/www:/var/www/html

#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
# M Y S Q L #
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
codeigniter4_mysql:
image: mariadb:10.5.5
container_name: 'codeigniter4_mysql'
ports:
- 3307:3306
volumes:
- ./localfolder/mysql:/var/lib/mysql
- ./localfolder/logs/mysql:/var/log/mysql
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: codeigniter4
MYSQL_USER: codeigniter4
MYSQL_PASSWORD: codeigniter4

#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
# P H P M Y A D M I N #
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
codeigniter4_phpmyadmin:
image: phpmyadmin/phpmyadmin:5.0.2
container_name: 'codeigniter4_phpmyadmin'
links:
- codeigniter4_mysql
environment:
PMA_HOST: codeigniter4_mysql
PMA_PORT: 3306
ports:
- 81:80
volumes:
- ./localfolder/sessions:/sessions
```


When I try to migrate for some reason, I cannot do it with an error.


```
localfolder\www\codeigniter4> php spark migrate

CodeIgniter v4.1.4 Command Line Tool - Server Time: 2021-09-20 03:17:33 UTC-05:00

Running all new migrations...

[CodeIgniter\Database\Exceptions\DatabaseException]

Unable to connect to the database.
Main connection [MySQLi]: php_network_getaddresses: getaddrinfo failed: ̂悤ȃzXg͕słB

at SYSTEMPATH\Database\BaseConnection.php:400

Backtrace:
  1    SYSTEMPATH\Database\BaseConnection.php:570
      CodeIgniter\Database\BaseConnection()->initialize()

  2    SYSTEMPATH\Database\BaseConnection.php:1320
      CodeIgniter\Database\BaseConnection()->query('SHOW TABLES FROM `codeigniter4`')

  3    SYSTEMPATH\Database\BaseConnection.php:1351
      CodeIgniter\Database\BaseConnection()->listTables()

  4    SYSTEMPATH\Database\MigrationRunner.php:754
      CodeIgniter\Database\BaseConnection()->tableExists('migrations')

  5    SYSTEMPATH\Database\MigrationRunner.php:166
      CodeIgniter\Database\MigrationRunner()->ensureTable()

  6    SYSTEMPATH\Commands\Database\Migrate.php:84
      CodeIgniter\Database\MigrationRunner()->latest(null)

  7    SYSTEMPATH\CLI\Commands.php:63
      CodeIgniter\Commands\Database\Migrate()->run([])

  8    SYSTEMPATH\CLI\CommandRunner.php:70
      CodeIgniter\CLI\Commands()->run('migrate', [])

  9    SYSTEMPATH\CLI\CommandRunner.php:56
      CodeIgniter\CLI\CommandRunner()->index([])

10    SYSTEMPATH\CodeIgniter.php:800
      CodeIgniter\CLI\CommandRunner()->_remap('index', 'migrate')

11    SYSTEMPATH\CodeIgniter.php:399
      CodeIgniter\CodeIgniter()->runController(Object(CodeIgniter\CLI\CommandRunner))

12    SYSTEMPATH\CodeIgniter.php:317
      CodeIgniter\CodeIgniter()->handleRequest(null, Object(Config\Cache), false)

13    SYSTEMPATH\CLI\Console.php:48
      CodeIgniter\CodeIgniter()->run()

14    ROOTPATH\spark:63
      CodeIgniter\CLI\Console()->run()[/php]
```

Please let me know if you can understand anything. thank you. Smile
Reply
#2

(This post was last modified: 09-21-2021, 05:25 PM by kenjis.)

Did you setup `.env` for database connection?

```
database.default.hostname = codeigniter4_mysql
database.default.database = codeigniter4
database.default.username = codeigniter4
database.default.password = codeigniter4
```
Reply




Theme © iAndrew 2016 - Forum software by © MyBB